-
Hi! Since I'm pretty new to Webpack and have never set up a React project with Webpack only (I have used either Craco or React Scripts), I am a bit stuck with my bundle size. The exact same application has a total bundle size of 5.3MB when I build via Craco, if I use Webpack with my custom config I get 18.9MB!. So clearly I have misconfigured something here... (since Craco also relies on Webpack in the end). I have tried all sorts of configs already but nothing seems to do anything with my bundle size. Here is my const configurationBuilder: DevConfigBuilderProps = env => {
return {
mode: "production",
output: {
path: resolve(__dirname, "build"),
asyncChunks: true,
clean: true,
},
optimization: {
minimize: true,
moduleIds: "deterministic",
nodeEnv: "production",
realContentHash: true,
removeAvailableModules: true,
removeEmptyChunks: true,
usedExports: true,
},
entry: resolve(__dirname, `${getAppDirectory(env.app)}/src/index.tsx`),
resolve: {
plugins: [PnpWebpackPlugin],
extensions: [".tsx", ".ts", ".js", ".jsx"],
alias: {
...sharedAliases,
...(env.app === "campus" ? campusAliases : env.app === "create" ? createAliases : signupAliases),
},
fallback: fallback,
},
resolveLoader: {
plugins: [PnpWebpackPlugin.moduleLoader(module)],
},
plugins: [
new HtmlWebpackPlugin({
template: resolve(__dirname, `${getAppDirectory(env.app)}/public/index.html`),
}),
new ProvidePlugin({ process: "process/browser.js" }),
new ProgressBarPlugin({ format: ` :msg [:bar] ${chalk.green.bold(":percent")} (:elapsed s)` }),
new BundleAnalyzerPlugin(),
],
module: {
rules: rules,
},
devtool: "source-map",
};
}; The Can anyone help? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
maybe craco build has several chunks in result? since both results are webpack build probably you can use https://www.npmjs.com/package/webpack-bundle-analyzer to compare results |
Beta Was this translation helpful? Give feedback.
maybe craco build has several chunks in result? since both results are webpack build probably you can use https://www.npmjs.com/package/webpack-bundle-analyzer to compare results