Skip to content

Commit

Permalink
fix: inspect the cause of higher memory requirement in prod build cre…
Browse files Browse the repository at this point in the history
…ation #1243
  • Loading branch information
duttarnab committed Aug 4, 2023
1 parent b47bb23 commit fcb4397
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 50 deletions.
54 changes: 6 additions & 48 deletions admin-ui/build/webpack.config.client.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CircularDependencyPlugin = require('circular-dependency-plugin')
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin
const CompressionPlugin = require("compression-webpack-plugin")

//const CompressionPlugin = require("compression-webpack-plugin")
const TerserWebpackPlugin = require('terser-webpack-plugin');
const config = require('./../config')
require('dotenv').config({
path: (process.env.NODE_ENV && `.env.${process.env.NODE_ENV}`) || '.env',
Expand All @@ -23,52 +23,13 @@ module.exports = {
devtool: false,
mode: 'production',
entry: {
app: [path.join(config.srcDir, 'index.js')],
app: [path.join(config.srcDir, 'index.js')]
},
optimization: {
moduleIds: 'named',
chunkIds: 'named',
minimize: true,
nodeEnv: 'production',
mangleWasmImports: true,
removeEmptyChunks: false,
mergeDuplicateChunks: false,
flagIncludedChunks: true,
minimizer: [`...`,
new CssMinimizerPlugin({
minimizerOptions: {
preset: [
"default",
{
calc: false,
discardComments: { removeAll: true },
},
],
},
}),
'...'],
emitOnErrors: true,
splitChunks: {
chunks: 'all',
minSize: 20000,
minRemainingSize: 0,
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
chunks: 'all'
},
minimizer: [`...`, new TerserWebpackPlugin(), new CssMinimizerPlugin(), `...`]
},
output: {
filename: '[name].bundle.js',
Expand Down Expand Up @@ -120,10 +81,7 @@ module.exports = {
SESSION_TIMEOUT_IN_MINUTES: JSON.stringify(SESSION_TIMEOUT_IN_MINUTES),
},
}),
new BundleAnalyzerPlugin({ analyzerMode: 'disabled' }), //* switch mode to "server" to activate BundleAnalyzerPlugin
new CompressionPlugin({
algorithm: "gzip",
})
new BundleAnalyzerPlugin({ analyzerMode: 'disabled' }) //* switch mode to "server" to activate BundleAnalyzerPlugin
],
module: {
rules: [
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
"babel-plugin-styled-components": "^2.0.7",
"circular-dependency-plugin": "^5.2.2",
"commander": "^10.0.0",
"compression-webpack-plugin": "^10.0.0",
"css-loader": "^6.7.3",
"css-minimizer-webpack-plugin": "^5.0.0",
"css-minimizer-webpack-plugin": "^5.0.1",
"eslint": "^8.37.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-import-resolver-alias": "^1.1.2",
Expand All @@ -91,6 +90,7 @@
"rimraf": "^4.4.1",
"sass-loader": "^13.2.2",
"style-loader": "^3.3.2",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.77.0",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
Expand Down

0 comments on commit fcb4397

Please sign in to comment.