Skip to content

Commit

Permalink
make production webpack build allow for node-env development for dev …
Browse files Browse the repository at this point in the history
…builds
  • Loading branch information
drewbo committed Jul 31, 2023
1 parent 94f5dc8 commit d981cff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
},
"scripts": {
"build": "webpack --config webpack.production.config.js",
"build-dev": "webpack --config webpack.development-build.config.js",
"start": "node index.js",
"start-workers": "node ./api/workers/index.js",
"start-bull-board:cg": "node -r ./api/bull-board/cfEnv.js ./api/bull-board/index.js",
Expand Down
12 changes: 8 additions & 4 deletions webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const RESOURCE_GENERATOR = {
};

module.exports = {
mode: 'production',
mode: process.env.NODE_ENV,
entry: './frontend/main.jsx',
devtool: process.env.NODE_ENV === 'development' ? 'inline-source-map' : null,
stats: process.env.NODE_ENV === 'minimal' ? 'minimal' : null,
output: {
filename: 'js/bundle.[contenthash].js',
filename: `js/bundle${process.env.NODE_ENV === 'production' ? '.[contenthash]' : ''}.js`,
path: path.resolve(__dirname, 'public'),
},
resolve: {
Expand All @@ -40,6 +42,7 @@ module.exports = {
{
loader: 'postcss-loader',
options: {
sourceMap: process.env.NODE_ENV === 'development',
postcssOptions: {
plugins: [autoprefixer],
},
Expand Down Expand Up @@ -90,11 +93,12 @@ module.exports = {
],
},
plugins: [
new MiniCssExtractPlugin({ filename: 'styles/styles.[contenthash].css' }),
// Make sure this is the first plugin!!!
new MiniCssExtractPlugin({ filename: `styles/styles${process.env.NODE_ENV === 'production' ? '.[contenthash]' : ''}.css` }),
// When webpack bundles moment, it includes all of its locale files,
// which we don't need, so we'll use this plugin to keep them out of the
// bundle
new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/}),
new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }),
new WebpackManifestPlugin({
fileName: '../webpack-manifest.json',
publicPath: '',
Expand Down

0 comments on commit d981cff

Please sign in to comment.