Skip to content

Commit

Permalink
Make both production and development builds available
Browse files Browse the repository at this point in the history
In order to allow the consuming apps to leverage friendly CSS class names and React tooling (PropTypes, StrictMode, etc.) during development this commit adds development builds of CSS and JS files into the `dist` folder.
  • Loading branch information
mbohal authored and adamkudrna committed Dec 4, 2023
1 parent b612e81 commit 311dd29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"npm": ">=9"
},
"scripts": {
"build": "webpack --mode=production",
"copy": "cp \"src/docs/_assets/generated/react-ui.css\" dist & cp \"src/docs/_assets/generated/react-ui.js\" dist",
"build": "webpack --mode=production && webpack --mode=development",
"copy": "npm run copy:css && npm run copy:js",
"copy:css": "cp src/docs/_assets/generated/react-ui.css dist && cp src/docs/_assets/generated/react-ui.development.css dist",
"copy:js": "cp src/docs/_assets/generated/react-ui.js dist && cp src/docs/_assets/generated/react-ui.development.js dist",
"eslint": "eslint --ext js,jsx src",
"jest": "jest src --coverage",
"lint": "npm run eslint && npm run markdownlint && npm run stylelint",
Expand Down
14 changes: 10 additions & 4 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ module.exports = (env, argv) => ({
],
},
optimization: {
minimize: true,
minimize: argv.mode === 'production',
minimizer: [new TerserPlugin()],
},
output: {
filename: '[name].js',
filename: argv.mode === 'production'
? '[name].js'
: '[name].development.js',
libraryTarget: 'umd',
path: Path.join(__dirname, 'src/docs/_assets/generated/'),
},
Expand All @@ -84,8 +86,12 @@ module.exports = (env, argv) => ({
},
plugins: [
new MiniCssExtractPlugin({
chunkFilename: '[id].css',
filename: '[name].css',
chunkFilename: argv.mode === 'production'
? '[id].css'
: '[id].development.css',
filename: argv.mode === 'production'
? '[name].css'
: '[name].development.css',
ignoreOrder: false, // Enable to remove warnings about conflicting order
}),
new StyleLintPlugin({
Expand Down

0 comments on commit 311dd29

Please sign in to comment.