After splitting into chunks, do I need to manually inject those chunk files, or will the main entry bundle automatically load them at runtime? #19966
Unanswered
ram-139-ar
asked this question in
Q&A
Replies: 1 comment 3 replies
-
I believe with |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
const path = require('path');
let BundleAnalyzerPlugin;
module.exports = (env, argv) => {
const isDevelopment = argv.mode === 'development'; // No I18N
if (isDevelopment) {
BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // No I18N
}
const webComponentsConfig = {
entry: {
'components/wd-render-text': './components/wd-render-text.ts' // No I18N
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'), // No I18N
clean: false,
publicPath: '/ui-lab/dev-releases/web-components/dist/'
},
module: {
rules: [
{
test: /.html$/,
loader: 'html-loader' // No I18N
},
{
test: /.ts$/,
use: {
loader: 'ts-loader', // No I18N
options: {
configFile: path.resolve(__dirname, 'tsconfig.json') // No I18N
}
},
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.ts', '.js'], // No I18N
alias: {
'web-pack-bundling': path.resolve(__dirname, '../../../web-pack-bundling'), // No I18N
'zd-cui': path.resolve(__dirname, '../../../zd-cui/addon') // No I18N
}
},
mode: argv.mode || 'development', // No I18N
devtool: isDevelopment ? 'eval-source-map' : false, // No I18N
...(isDevelopment && {
optimization: {
usedExports: true, // Enables tree shaking in development
sideEffects: true, // Respect package.json sideEffects
minimize: false, // Don't minify in dev
splitChunks: {
cacheGroups: {
common_web: {
minSize: 1000, // means 1000 bytes
maxSize: 4000, // means 4 KB
minChunks: 2,
reuseExistingChunk: true,
chunks: 'all',
}
}
}
}
}),
...!isDevelopment && {
optimization: {
usedExports: true, // Enables tree shaking in production
sideEffects: true, // Respect package.json sideEffects
minimize: true,
splitChunks: {
cacheGroups: {
common_web: {
minSize: 1000, // means 100 bytes
maxSize: 4000, // means 3 KB
filename: 'common.[contenthash].chunk.js',
minChunks: 2,
reuseExistingChunk: true,
chunks: 'all'
}
}
}
}
},
externals: {
baseContext: 'WdContexts' // No I18N
},
plugins: isDevelopment ? [
new BundleAnalyzerPlugin({
analyzerMode: 'static', // No I18N
openAnalyzer: false, // Automatically opens report in browser
reportFilename: 'web-components-report.html' // No I18N
})
] : []
};
return webComponentsConfig;
};
Beta Was this translation helpful? Give feedback.
All reactions