Skip to content

Commit 311dd29

Browse files
mbohaladamkudrna
authored andcommitted
Make both production and development builds available
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.
1 parent b612e81 commit 311dd29

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
"npm": ">=9"
3434
},
3535
"scripts": {
36-
"build": "webpack --mode=production",
37-
"copy": "cp \"src/docs/_assets/generated/react-ui.css\" dist & cp \"src/docs/_assets/generated/react-ui.js\" dist",
36+
"build": "webpack --mode=production && webpack --mode=development",
37+
"copy": "npm run copy:css && npm run copy:js",
38+
"copy:css": "cp src/docs/_assets/generated/react-ui.css dist && cp src/docs/_assets/generated/react-ui.development.css dist",
39+
"copy:js": "cp src/docs/_assets/generated/react-ui.js dist && cp src/docs/_assets/generated/react-ui.development.js dist",
3840
"eslint": "eslint --ext js,jsx src",
3941
"jest": "jest src --coverage",
4042
"lint": "npm run eslint && npm run markdownlint && npm run stylelint",

webpack.config.babel.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ module.exports = (env, argv) => ({
6565
],
6666
},
6767
optimization: {
68-
minimize: true,
68+
minimize: argv.mode === 'production',
6969
minimizer: [new TerserPlugin()],
7070
},
7171
output: {
72-
filename: '[name].js',
72+
filename: argv.mode === 'production'
73+
? '[name].js'
74+
: '[name].development.js',
7375
libraryTarget: 'umd',
7476
path: Path.join(__dirname, 'src/docs/_assets/generated/'),
7577
},
@@ -84,8 +86,12 @@ module.exports = (env, argv) => ({
8486
},
8587
plugins: [
8688
new MiniCssExtractPlugin({
87-
chunkFilename: '[id].css',
88-
filename: '[name].css',
89+
chunkFilename: argv.mode === 'production'
90+
? '[id].css'
91+
: '[id].development.css',
92+
filename: argv.mode === 'production'
93+
? '[name].css'
94+
: '[name].development.css',
8995
ignoreOrder: false, // Enable to remove warnings about conflicting order
9096
}),
9197
new StyleLintPlugin({

0 commit comments

Comments
 (0)