Answer the question
In order to leave comments, you need to log in
Webpack, how to process each file, and not combine everything into one bundle?
I have a React + Typescript component library.
I was puzzled by the issue of trishaking, now when building Webpack 5:
output: {
path: path.join(__dirname, '/dist'),
filename: pkg.name + 'js,
library: pkg.name,
libraryTarget: 'umd',
umdNamedDefine: true,
},
Answer the question
In order to leave comments, you need to log in
snowpack does this by default, building into a common bundle is an option there.
I assume that the obvious option with tsc directly does not suit you due to the lack of loaders for css, for example.
maybe something like that?
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `vendor-${packageName.replace('@', '')}`;
},
},
app: {
name: 'app',
enforce: true,
maxSize: 249856,
chunks: 'all',
},
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question