1.项目中需要频繁的build ,插件比较多 构建很慢 使用dllplugin将不需要重复打包的第三方库分离出来
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
vendor: [
'vue/dist/vue.esm.js',
'vue-router',
'babel-polyfill'
]
},
output: {
path: path.join(__dirname, '../static/js'),
filename: '[name].dll.js',
library: '[name]_library'
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, '.', '[name]-manifest.json'),
name: '[name]_library'
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console:true,
drop_debugger:true
},
output:{
comments: false,
},
sourceMap: true
})
]
};
如图是node_modules下的几个第三方库
问题一:node_modules下的那么多第三方库 都需要一个个列举在这边吗?
问题二:如果想忽略指定文件夹下的文件怎么办?
dll的作用是预编译,提前把不需要频繁改动的包,或者静态文件打包为一个js文件和映射json;好处1、打包速度快;2、方便缓存 ;可以参考该项目https://github.com/NewPrototy...