2024-10-14 11:35:56 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 配置参考:
|
|
|
|
|
|
* https://cli.vuejs.org/zh/config/
|
|
|
|
|
|
*/
|
2024-12-14 02:49:27 +00:00
|
|
|
|
const url = 'http://mom-gateway:9999'
|
|
|
|
|
|
// const url = 'http://192.168.110.148:11001/'
|
2024-11-28 09:12:12 +00:00
|
|
|
|
// const url = 'http://192.168.100.8:11001'
|
2024-10-14 11:35:56 +00:00
|
|
|
|
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
|
|
|
|
|
const productionGzipExtensions = ['js', 'css']
|
|
|
|
|
|
const path = require('path')
|
|
|
|
|
|
const FileManagerPlugin = require('filemanager-webpack-plugin')
|
|
|
|
|
|
|
|
|
|
|
|
function resolve(dir) {
|
|
|
|
|
|
return path.join(__dirname, dir)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
lintOnSave: true,
|
|
|
|
|
|
productionSourceMap: false,
|
2024-12-13 03:18:58 +00:00
|
|
|
|
chainWebpack: (config) => {
|
2024-10-14 11:35:56 +00:00
|
|
|
|
const entry = config.entry('app')
|
2024-12-13 03:18:58 +00:00
|
|
|
|
entry.add('babel-polyfill').end()
|
|
|
|
|
|
entry.add('classlist-polyfill').end()
|
2024-10-14 11:35:56 +00:00
|
|
|
|
// set svg-sprite-loader
|
2024-12-13 03:18:58 +00:00
|
|
|
|
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end()
|
2024-10-14 11:35:56 +00:00
|
|
|
|
config.module
|
|
|
|
|
|
.rule('icons')
|
|
|
|
|
|
.test(/\.svg$/)
|
|
|
|
|
|
.include.add(resolve('src/assets/icons'))
|
|
|
|
|
|
.end()
|
|
|
|
|
|
.use('svg-sprite-loader')
|
|
|
|
|
|
.loader('svg-sprite-loader')
|
|
|
|
|
|
.options({
|
2024-12-13 03:18:58 +00:00
|
|
|
|
symbolId: 'icon-[name]',
|
2024-10-14 11:35:56 +00:00
|
|
|
|
})
|
|
|
|
|
|
.end()
|
|
|
|
|
|
config.module
|
|
|
|
|
|
.rule('tsx')
|
|
|
|
|
|
.test(/\.tsx?$/)
|
|
|
|
|
|
.use('ts-loader')
|
|
|
|
|
|
.loader('ts-loader')
|
|
|
|
|
|
.options({
|
2024-12-13 03:18:58 +00:00
|
|
|
|
appendTsSuffixTo: [/\.vue$/],
|
2024-10-14 11:35:56 +00:00
|
|
|
|
})
|
2024-12-13 03:18:58 +00:00
|
|
|
|
.tap((options) => {
|
2024-10-14 11:35:56 +00:00
|
|
|
|
return options
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
css: {
|
|
|
|
|
|
// 忽略 CSS order 顺序警告
|
2024-12-13 03:18:58 +00:00
|
|
|
|
extract: { ignoreOrder: true },
|
2024-10-14 11:35:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
configureWebpack: (config) => {
|
|
|
|
|
|
let deleteOriginalAssets = false
|
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
|
|
// 仅在生产环境下启用该配置
|
|
|
|
|
|
deleteOriginalAssets = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let fileManagerPlugin = new FileManagerPlugin({
|
|
|
|
|
|
events: {
|
|
|
|
|
|
onEnd: {
|
|
|
|
|
|
delete: ['./target'],
|
|
|
|
|
|
mkdir: ['./target'],
|
2024-12-13 03:18:58 +00:00
|
|
|
|
copy: [
|
|
|
|
|
|
{
|
|
|
|
|
|
source: './dist',
|
|
|
|
|
|
destination: './target/dist/dist/',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
archive: [
|
|
|
|
|
|
{
|
|
|
|
|
|
source: './target/dist',
|
|
|
|
|
|
destination: './target/dist.zip',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-10-14 11:35:56 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
let configure = {
|
|
|
|
|
|
performance: {
|
|
|
|
|
|
// 打包后最大文件大小限制
|
2024-12-13 03:18:58 +00:00
|
|
|
|
maxAssetSize: 1024000,
|
2024-10-14 11:35:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
new CompressionWebpackPlugin({
|
|
|
|
|
|
filename: '[path].gz[query]',
|
|
|
|
|
|
algorithm: 'gzip',
|
|
|
|
|
|
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
|
|
|
|
|
|
threshold: 1024, // 只有大小大于该值的资源会被处理,当前配置为对于超过1k的数据进行处理,不足1k的可能会越压缩越大
|
|
|
|
|
|
minRatio: 0.99, // 只有压缩率小于这个值的资源才会被处理
|
2024-12-13 03:18:58 +00:00
|
|
|
|
deleteOriginalAssets: deleteOriginalAssets, // 删除原文件
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
2024-10-14 11:35:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
|
|
configure.plugins.push(fileManagerPlugin)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
|
// 開發環境使用
|
|
|
|
|
|
// configure.devtool = 'source-map'
|
|
|
|
|
|
}
|
|
|
|
|
|
return configure
|
|
|
|
|
|
},
|
|
|
|
|
|
// 配置转发代理
|
|
|
|
|
|
devServer: {
|
|
|
|
|
|
disableHostCheck: true,
|
|
|
|
|
|
port: 8080,
|
|
|
|
|
|
proxy: {
|
|
|
|
|
|
'/': {
|
|
|
|
|
|
target: url,
|
|
|
|
|
|
ws: false, // 需要websocket 开启
|
|
|
|
|
|
pathRewrite: {
|
2024-12-13 03:18:58 +00:00
|
|
|
|
'^/': '/',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-10-14 11:35:56 +00:00
|
|
|
|
}
|