这是bundle-analyzer的输出:
正如您所看到的,像react-dom、jquery和mobx这样的包都在shell bundle和vendor bundle中。是否可能只将它们放在vendor bundle中?
更新
以下是配置文件:
entry: {
shell: './src/shell.ts',
vendor: [
'jquery',
'react',
'react-dom',
'react-router',
'mobx',
'mobx-react',
'toastr',
'styled-components',
],
},
output: {
path: __dirname + '/dist',
filename: '[name]bundle.js?[hash:8]',
publicPath: '/',
},
devtool: PROD ? false : 'source-map',
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.json'],
modules: ['node_modules'],
},
optimization: {
minimize: !!PROD,
},
plugins: [
new CleanWebpackPlugin(['dist']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new ExtractTextPlugin('[name].css?[hash:8]', {
allChunks: true,
disable: !PROD,
}),
new HtmlWebpackPlugin({
chunksSortMode: 'dependency',
template: './src/index.tpl.html',
}),
new BundleAnalyzerPlugin(),
],