如下是本人的Vue cli3 Dll 配置 (如遇問題請聯繫)vue
/*
* @Description:Dll配置信息
* @Author: 吳文周
* @Github: https://github.com/fodelf
* @Date: 2019-06-04 17:39:53
* @LastEditors: 吳文周
* @LastEditTime: 2019-10-16 09:53:49
*/
const path = require('path')
const webpack = require('webpack')
const CleanWebpackPlugin = require('clean-webpack-plugin')
// dll文件存放的目錄
const dllPath = 'public/vendor'
module.exports = {
entry: {
// 須要提取的庫文件
vendor: ['vue', 'vue-router', 'vuex', 'axios', 'element-ui']
},
output: {
path: path.join(__dirname, dllPath),
filename: '[name].dll.js',
// vendor.dll.js中暴露出的全局變量名
// 保持與 webpack.DllPlugin 中名稱一致
library: '[name]_[hash]'
},
plugins: [
// 清除以前的dll文件
new CleanWebpackPlugin(['*.*'], {
root: path.join(__dirname, dllPath)
}),
// 設置環境變量
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: 'production'
}
}),
// manifest.json 描述動態連接庫包含了哪些內容
new webpack.DllPlugin({
path: path.join(__dirname, dllPath, '[name]-manifest.json'),
// 保持與 output.library 中名稱一致
name: '[name]_[hash]',
context: process.cwd()
})
]
}複製代碼