Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement #972

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 66 additions & 10 deletions frontend/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,70 @@
// config-overrides.js
const {
override,
addWebpackPlugin,
fixBabelImports,
} = require("customize-cra");
// const CompressionPlugin = require("compression-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
module.exports = function override(config, env) {
if (env === "production") {
config.devtool = "source-map";
// config.devtool = 'cheap-module-source-map';
}
config.plugins.push(
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

module.exports = override(
fixBabelImports("import", {
libraryName: "antd",
libraryDirectory: "es",
style: "css",
}),

(config) => {
const env = process.env.NODE_ENV;
if (env === "production") {
config.devtool = "source-map";
config.optimization = {
...config.optimization,
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
}),
],
};

// save for future use, if needed to compress the assets

// config.plugins.push(
// new CompressionPlugin({
// filename: "[path][base].gz",
// algorithm: "gzip",
// test: /\.(js|css|html|svg)$/,
// threshold: 10240,
// minRatio: 0.8,
// deleteOriginalAssets: false,
// })
// );
}

config.stats = {
all: true,
timings: true,
assets: true,
chunks: true,
modules: true,
};

return config;
},

addWebpackPlugin(
new webpack.DefinePlugin({
"process.env.SITE_NAME": JSON.stringify(process.env.SITE_NAME),
}),
);
return config;
};
),

// Uncomment the following line to enable the bundle analyzer, for debugging purposes
// addWebpackPlugin(new BundleAnalyzerPlugin()),
);
Loading
Loading