Files
refinery-admin/vue.config.js

125 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-05-12 14:21:04 +08:00
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
2023-02-09 15:51:21 +08:00
function resolve(dir) {
2023-05-12 14:21:04 +08:00
return path.join(__dirname, dir)
2023-02-09 15:51:21 +08:00
}
2023-05-12 14:21:04 +08:00
const name = defaultSettings.title || 'vue Admin Template'
2023-02-09 15:51:21 +08:00
module.exports = {
2023-05-12 14:21:04 +08:00
publicPath: '/refinery',
outputDir: 'dist',
assetsDir: 'static',
2023-02-09 15:51:21 +08:00
productionSourceMap: false,
devServer: {
inline: true,
2023-04-28 13:11:46 +08:00
port: 9530,
2023-02-09 15:51:21 +08:00
open: false,
overlay: {
warnings: false,
2023-05-12 14:21:04 +08:00
errors: true
2023-02-09 15:51:21 +08:00
},
disableHostCheck: true,
// before: require('./mock/mock-server.js'),
proxy: {
[process.env.VUE_APP_BASE_API]: {
// target: `https://3816t6291y.oicp.vip`,
// target: 'https://6l438d1757.zicp.fun',
2023-05-12 14:21:04 +08:00
target: 'http://192.168.1.85:38080',
2023-05-16 09:30:27 +08:00
// target: 'http://222.132.26.119:8081',
2023-02-28 09:40:07 +08:00
// target: "http://uat.xingoil.com/adminapi",
2023-02-09 15:51:21 +08:00
changeOrigin: true,
pathRewrite: {
2023-05-12 14:21:04 +08:00
['^' + process.env.VUE_APP_BASE_API]: ''
}
}
}
2023-02-09 15:51:21 +08:00
},
configureWebpack: {
name: name,
resolve: {
alias: {
2023-05-12 14:21:04 +08:00
'@': resolve('src'),
api: resolve('src/api'),
utils: resolve('src/utils'),
views: resolve('src/views'),
assets: resolve('src/assets'),
components: resolve('src/components')
}
}
2023-02-09 15:51:21 +08:00
},
chainWebpack(config) {
2023-05-12 14:21:04 +08:00
config.plugin('preload').tap(() => [
2023-02-09 15:51:21 +08:00
{
2023-05-12 14:21:04 +08:00
rel: 'preload',
2023-02-09 15:51:21 +08:00
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
2023-05-12 14:21:04 +08:00
include: 'initial'
}
])
2023-02-09 15:51:21 +08:00
2023-05-12 14:21:04 +08:00
config.plugins.delete('prefetch')
2023-02-09 15:51:21 +08:00
2023-05-12 14:21:04 +08:00
config.module.rule('svg').exclude.add(resolve('src/icons')).end()
2023-02-09 15:51:21 +08:00
config.module
2023-05-12 14:21:04 +08:00
.rule('icons')
2023-02-09 15:51:21 +08:00
.test(/\.svg$/)
2023-05-12 14:21:04 +08:00
.include.add(resolve('src/icons'))
2023-02-09 15:51:21 +08:00
.end()
2023-05-12 14:21:04 +08:00
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
2023-02-09 15:51:21 +08:00
.options({
2023-05-12 14:21:04 +08:00
symbolId: 'icon-[name]'
2023-02-09 15:51:21 +08:00
})
2023-05-12 14:21:04 +08:00
.end()
2023-02-09 15:51:21 +08:00
config.module
2023-05-12 14:21:04 +08:00
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
2023-02-09 15:51:21 +08:00
})
2023-05-12 14:21:04 +08:00
.end()
2023-02-09 15:51:21 +08:00
2023-05-12 14:21:04 +08:00
config.when(process.env.NODE_ENV !== 'development', config => {
2023-02-09 15:51:21 +08:00
config
2023-05-12 14:21:04 +08:00
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [
2023-02-09 15:51:21 +08:00
{
2023-05-12 14:21:04 +08:00
inline: /runtime\..*\.js$/
}
2023-02-09 15:51:21 +08:00
])
2023-05-12 14:21:04 +08:00
.end()
2023-02-09 15:51:21 +08:00
config.optimization.splitChunks({
2023-05-12 14:21:04 +08:00
chunks: 'all',
2023-02-09 15:51:21 +08:00
cacheGroups: {
libs: {
2023-05-12 14:21:04 +08:00
name: 'chunk-libs',
2023-02-09 15:51:21 +08:00
test: /[\\/]node_modules[\\/]/,
priority: 10,
2023-05-12 14:21:04 +08:00
chunks: 'initial'
2023-02-09 15:51:21 +08:00
},
elementUI: {
2023-05-12 14:21:04 +08:00
name: 'chunk-elementUI',
2023-02-09 15:51:21 +08:00
priority: 20,
2023-05-12 14:21:04 +08:00
test: /[\\/]node_modules[\\/]_?element-ui(.*)/
2023-02-09 15:51:21 +08:00
},
commons: {
2023-05-12 14:21:04 +08:00
name: 'chunk-commons',
test: resolve('src/components'),
2023-02-09 15:51:21 +08:00
minChunks: 3,
priority: 5,
2023-05-12 14:21:04 +08:00
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single')
})
2023-02-09 15:51:21 +08:00
},
2023-05-12 14:21:04 +08:00
lintOnSave: false
}