95 lines
2.0 KiB
JavaScript
95 lines
2.0 KiB
JavaScript
const path = require('path')
|
|
const appType = process.env.VUE_APP_TYPE
|
|
|
|
function resolve(dir) {
|
|
return path.join(__dirname, dir)
|
|
}
|
|
|
|
function getProxyTargetPort() {
|
|
switch (appType) {
|
|
case 'frps':
|
|
return 8081
|
|
case 'frpc':
|
|
return 8082
|
|
default:
|
|
return 8080
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
publicPath: './',
|
|
outputDir: `./dist/${appType}`,
|
|
productionSourceMap: false,
|
|
devServer: {
|
|
host: '127.0.0.1',
|
|
port: 8010,
|
|
proxy: {
|
|
'/api/': {
|
|
target: `http://127.0.0.1:${getProxyTargetPort()}/api`,
|
|
changeOrigin: true,
|
|
pathRewrite: {
|
|
'^/api': ''
|
|
}
|
|
}
|
|
}
|
|
},
|
|
configureWebpack: config => {
|
|
config.optimization = {
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
vendor: {
|
|
chunks: 'all',
|
|
test: /node_modules/,
|
|
name: 'vendor',
|
|
minChunks: 1,
|
|
maxInitialRequests: 5,
|
|
minSize: 0,
|
|
priority: 100
|
|
},
|
|
common: {
|
|
chunks: 'all',
|
|
test: /[\\/]src[\\/]js[\\/]/,
|
|
name: 'common',
|
|
minChunks: 2,
|
|
maxInitialRequests: 5,
|
|
minSize: 0,
|
|
priority: 60
|
|
},
|
|
styles: {
|
|
name: 'styles',
|
|
test: /\.(sa|sc|c)ss$/,
|
|
chunks: 'all',
|
|
enforce: true
|
|
},
|
|
runtimeChunk: {
|
|
name: 'manifest'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
chainWebpack(config) {
|
|
config.plugins.delete('preload')
|
|
config.plugins.delete('prefetch')
|
|
|
|
// set svg-sprite-loader
|
|
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()
|
|
|
|
config.when(process.env.NODE_ENV === 'development', config => config.devtool('eval-source-map'))
|
|
}
|
|
}
|