webpack代码分离CommonsChunkPlugin插件的使用(防止重复)

 1.webpack.config.js中添加:


const path = require('path'); + const webpack = require('webpack'); const HTMLWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: { index: './src/index.js', another: './src/another-module.js' }, plugins: [ new HTMLWebpackPlugin({ title: 'Code Splitting' - }) + }), + new webpack.optimize.CommonsChunkPlugin({ + name: 'common' // 指定公共 bundle 的名称。 + }) ], output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') } };

猜你喜欢

转载自www.cnblogs.com/zhanyuefeixian/p/11933937.html