106 lines
3.2 KiB
JavaScript
106 lines
3.2 KiB
JavaScript
const TerserPlugin = require('terser-webpack-plugin');
|
|
const copyWebpackPlugin = require('copy-webpack-plugin')
|
|
// const purgecss = require('@fullhuman/postcss-purgecss')({
|
|
// content: [
|
|
// './src/**/*.html',
|
|
// './src/**/*.vue',
|
|
// './src/**/*.jsx',
|
|
// ],
|
|
//
|
|
// // Include any special characters you're using in this regular expression
|
|
// defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
|
|
// })
|
|
|
|
const path = require('path')
|
|
|
|
function resolve(dir) {
|
|
return path.join(__dirname, dir)
|
|
}
|
|
|
|
module.exports = {
|
|
assetsDir: 'static',
|
|
runtimeCompiler: process.env.NODE_ENV !== 'production',
|
|
// runtimeCompiler: true,
|
|
productionSourceMap: process.env.NODE_ENV !== 'production',
|
|
// productionSourceMap: true,
|
|
publicPath: "/",
|
|
pages: {
|
|
index: "./src/views/home/main.ts",
|
|
dashboard: {
|
|
entry:"./src/views/home/main.ts",
|
|
template: 'public/index.html',
|
|
filename: 'dashboard/index.html',
|
|
title: '包管理系统',
|
|
chunks: ['chunk-vendors', 'chunk-common', 'dashboard']
|
|
},
|
|
admin: {
|
|
entry: './src/views/admin/main.ts',
|
|
template: 'public/index.html',
|
|
filename: 'admin/index.html',
|
|
title: '包管理系统',
|
|
chunks: ['chunk-vendors', 'chunk-common', 'admin']
|
|
},
|
|
wap: {
|
|
entry: './src/views/wap/main.ts',
|
|
template: 'public/index.html',
|
|
filename: 'wap/index.html',
|
|
title: '包管理系统',
|
|
chunks: ['chunk-vendors', 'chunk-common', 'wap']
|
|
}
|
|
},
|
|
chainWebpack: config => {
|
|
// const svgRule = config.module.rule('svg')
|
|
// svgRule.uses.clear()
|
|
// svgRule
|
|
// .use('svg-sprite-loader')
|
|
// .loader('svg-sprite-loader')
|
|
// .options({
|
|
// symbolId: 'icon-[name]'
|
|
// });
|
|
config.optimization.minimizer('terser')
|
|
.tap(items => {
|
|
items = items.map(item => {
|
|
Object.assign(item.terserOptions.compress, {
|
|
pure_funcs: ['console.log'],
|
|
drop_console: true
|
|
})
|
|
return item;
|
|
})
|
|
return items
|
|
})
|
|
|
|
config.module
|
|
.rule('svg')
|
|
.exclude.add(resolve('src/icons'))
|
|
.end()
|
|
config.module
|
|
.rule('icons')
|
|
.test(/\.svg$/)
|
|
.include.add(resolve('src/icons'))
|
|
.end()
|
|
.use('svg-sprite-loader')
|
|
.loader('svg-sprite-loader')
|
|
.options({
|
|
symbolId: 'icon-[name]'
|
|
})
|
|
.end()
|
|
|
|
return config;
|
|
},
|
|
configureWebpack: {
|
|
plugins: [
|
|
new copyWebpackPlugin([
|
|
{from: "public/.htaccess", to: "dashboard/"},
|
|
{from: "public/.htaccess", to: "admin/"},
|
|
{from: "public/.htaccess", to: "wap/"},
|
|
], {copyUnmodified: true}),
|
|
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve('src'),
|
|
'views': resolve('src/views')
|
|
}
|
|
}
|
|
}
|
|
} |