xlb-main-login
Version:
``` yarn install ```
84 lines (75 loc) • 1.94 kB
JavaScript
const webpack = require('webpack')
const { resolve } = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const dllPath = './dll'
const bundle = [
'vue',
'vue-router',
'vuex',
'lodash',
'wangeditor',
'@antv/g2',
'@antv/data-set',
'quill',
'ant-design-vue',
'axios',
'core-js',
]
module.exports = {
mode: 'production',
entry: {
bundle,
},
output: {
path: resolve(__dirname, dllPath), // 路径
filename: '[name].dll.js', // 文件名
library: '[name]', // 与打包后的文件的返回值绑定
},
// module: {
// rules: [
// {
// test: /\.css$/,
// use: [
// {
// loader: MiniCssExtractPlugin.loader,
// options: {
// // 这里可以指定一个 publicPath
// // 默认使用 webpackOptions.output中的publicPath
// publicPath: '../'
// }
// },
// 'css-loader'
// ]
// }
// ]
// },
plugins: [
// 清除之前的dll文件
new CleanWebpackPlugin(),
new webpack.DllPlugin({
context: __dirname, // 可选参数,manifest 文件中请求的上下文(默认值为 webpack 的上下文)
path: resolve(__dirname, dllPath, '[name]-manifest.json'), // manifest.json 文件的路径
name: '[name]', // 暴露出来的Dll函数名,必须跟output.library保持一致
}),
// new MiniCssExtractPlugin({
// filename: '[name].dll.css',
// chunkFilename: '[id].css'
// })
new UglifyJSPlugin({
uglifyOptions: {
warnings: false,
mangle: true,
output: {
comments: false,
beautify: false,
},
compress: {
drop_debugger: true,
drop_console: true,
dead_code: true,
},
},
}),
],
}