trqVue/vue.config.js
2025-03-09 19:40:08 +08:00

133 lines
4.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require('path')
const CompressionPlugin = require('compression-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
// vue.config.js
module.exports = {
/*
Vue-cli3:
Crashed when using Webpack `import()` #2463
https://github.com/vuejs/vue-cli/issues/2463
*/
// 如果你不需要生产环境的 source map可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false,
// 打包app时放开该配置
// publicPath:'./',
configureWebpack: config => {
// 生产环境取消 console.log
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
}
},
chainWebpack: (config) => {
config.resolve.alias
.set('@$', resolve('src'))
.set('@api', resolve('src/api'))
.set('@assets', resolve('src/assets'))
.set('@comp', resolve('src/components'))
.set('@views', resolve('src/views'))
.set('@layout', resolve('src/layout'))
.set('@static', resolve('src/static'))
.set('@mobile', resolve('src/modules/mobile'))
// 生产环境开启js\css压缩
if (process.env.NODE_ENV === 'production') {
config.plugin('compressionPlugin').use(new CompressionPlugin({
test: /\.js$|.\css|.\less/, // 匹配文件名
threshold: 10240, // 对超过10k的数据压缩
deleteOriginalAssets: false // 不删除源文件
}))
}
// 配置 webpack 识别 markdown 为普通的文件
config.module
.rule('markdown')
.test(/\.md$/)
.use()
.loader('file-loader')
.end()
},
css: {
loaderOptions: {
less: {
modifyVars: {
/* less 变量覆盖,用于自定义 ant design 主题 */
'primary-color': '#1890FF',
'link-color': '#1890FF',
'border-radius-base': '4px'
},
javascriptEnabled: true
}
}
},
// 发布时需要修改下面的地址
devServer: {
port: 3000,
proxy: {
'/Gyk': {
// target: 'http://10.75.15.251:9999', // mock API接口系统
// target: 'http://10.80.20.224:9999', // mock API接口系统
target: 'http://10.75.166.6:9999', // mock API接口系统
ws: false,
changeOrigin: true,
pathRewrite: {
'/jeecg-boot': '' // 默认所有请求都加了jeecg-boot前缀需要去掉
}
},
'/jeecg-boot': {
target: 'http://10.75.15.249:8080', // 请求本地 需要jeecg-boot后台项目开发用
// target: 'http://10.75.166.165:8080', // 请求本地 需要jeecg-boot后台项目开发用
// target: 'http://10.75.241.180:8080', // 请求本地 需要jeecg-boot后台项目开发用
// target: 'http://10.75.166.6:8080', // 请求本地 需要jeecg-boot后台项目(发布用)
ws: false,
changeOrigin: true
},
'/ssologin': {
target: 'http://10.75.166.6', // 请求本地 单点登录后台项目
// target: 'http://10.75.241.180', // 请求信创 单点登录后台项目
// target: 'https://10.75.166.165:8013', // 请求本地 单点登录后台项目测试
ws: false,
changeOrigin: true
},
'/exam': {
target: 'http://10.75.166.170:8101', // 请求考试系统后端
ws: false,
changeOrigin: true
},
'/ThingsBoard': {
// target: 'http://10.75.15.251:8888', // 新增thingsBoard接口 jiang20240929
target: 'http://10.75.166.6:8888', // 新增thingsBoard接口 jiang20240929
ws: false,
changeOrigin: true
},
'/mqttprod': {
// target: 'http://10.75.15.246:8899', // 新增mqtt接口 张祥瑞20241119
target: 'http://10.75.166.6:8899', // 新增mqtt接口 张祥瑞20241119
ws: false,
changeOrigin: true
},
// '/view': {
// target: 'http://10.75.166.159:8012', // 请求预览后台项目
// ws: false,
// changeOrigin: true
// }
'/pageOffice': {
target: 'http://10.75.166.173:8080/jeecg-boot', //pageOffice
ws: true,
changeOrigin: true, // 允许跨域
pathRewrite: {
'/pageOffice': '' // 标识替换,使用 '/pageOffice' 代替真实的接口地址
}
}
}
},
lintOnSave: false
}