DLLPlugin 和 DLLReferencePlugin Vuecli 3.0
在vue项目,在打包的过程中将,常用的包进行提前打包,节省之后打包的时间。
1.新增库打包文件webpack.dll.conf
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const package = require('./package.json');
const dllPath = package.dllPath; // 输出打包后的目录
module.exports = {
entry: {
// 需要提取的库文件
vendor: ['vue', 'vue-router', 'vuex', 'axios', 'element-ui', 'html2canvas', 'vconsole', 'vue-axios', 'v-viewer']
},
output: {
path: path.join(__dirname, dllPath),
filename: 'dfg.[name].dll.[hash:8].js',
library: '[name]_[hash]'
},
plugins: [
new CleanWebpackPlugin(), // https://www