20 Star 226 Fork 123

中台 / Admin.UI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vue.config.js 3.50 KB
一键复制 编辑 原始数据 按行查看 历史
xiaoxue 提交于 2022-10-21 19:41 . 修正多项目接口同步
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
const CompressionPlugin = require('compression-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
const isDev = process.env.NODE_ENV === 'development'
const name = defaultSettings.title || '中台admin'
// 官方配置说明 https://cli.vuejs.org/zh/config/#vue-config-js
module.exports = {
// 基本路径
publicPath: '/',
// 输出文件目录
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: isDev,
productionSourceMap: false,
devServer: {
// 自动启动浏览器
open: true,
port: 9000,
// 浏览器弹出错误
overlay: {
warnings: false,
errors: true
},
// 配置多个代理
// detail: https://cli.vuejs.org/config/#devserver-proxy
proxy: {
['^' + process.env.VUE_APP_BASE_API]: {
target: 'http://localhost:8000',
changeOrigin: true
},
'^/upload': {
target: 'http://localhost:8000',
changeOrigin: true
},
'^/images': {
target: 'http://localhost:8000',
changeOrigin: true
},
'^/swagger-resources': {
target: 'http://localhost:8000',
changeOrigin: true
},
'^/swagger': {
target: 'http://localhost:8000',
changeOrigin: true
}
}
},
css: {
loaderOptions: {
sass: {
sassOptions: { outputStyle: 'expanded' }
}
}
},
configureWebpack: {
name: name,
resolve: {
alias: {
'@': resolve('src')
}
},
// 发布时关闭警告
performance: {
hints: false
},
plugins: [
// 使用gzip解压缩静态文件
new CompressionPlugin({
cache: false, // 不启用文件缓存
test: /\.(js|css|html)?$/i, // 压缩文件格式
filename: '[path].gz[query]', // 压缩后的文件名
algorithm: 'gzip', // 使用gzip压缩
minRatio: 0.8 // 压缩率小于1才会压缩
})
]
},
// webpack配置
chainWebpack(config) {
config.plugins.delete('prefetch')
config.plugins.delete('preload')
// config.when(isDev, config => config.devtool('cheap-source-map'))
config.when(!isDev,
config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}])
.end()
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single')
})
}
}
JavaScript
1
https://gitee.com/zhontai/Admin.UI.git
git@gitee.com:zhontai/Admin.UI.git
zhontai
Admin.UI
Admin.UI
master

搜索帮助