zhly-web/vue.config.js

88 lines
2.9 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 { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
publicPath: './',
// 生产环境构建文件的目录名
outputDir: 'dist',
// 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
assetsDir: '',
transpileDependencies: true,
lintOnSave: false,
devServer: { //设置本地默认端口 选填
//disableHostCheck: true, //内网host解析域名穿透需要加上 disableHostCheck
port: '8888',
open:true,
proxy: {
'/build_api': {
// target: 'http://192.168.0.14:18081',//测试
// target: 'http://192.168.0.7:18080',//测试
target: 'http://192.168.0.7:20048',//测试
// target: 'http://36.33.26.201:20048',//外网
// target: 'http://192.168.0.39:18080', //本地
// target: 'http://192.168.0.235:18080', //本地
// target: 'http://10.40.92.31:28080', //本地
changeOrigin: true,
// ws: true,
// changeOrigin: true,
pathRewrite: {
'^/build_api/': ''
},
headers:{
'Access-Control-Allow-Origin':'*'
}
},
// '/build_api': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
// target: 'http://192.168.0.39:18080/zhly_web_back', //代理的目标地址
// changeOrigin: true, //是否设置同源,输入是的
// pathRewrite: { //路径重写
// '^/build_api': '' //选择忽略拦截器里面的内容
// }
// },
},
client: {
overlay: false
}
},
css: {
sourceMap: true, // 开启 CSS source maps
loaderOptions: {
sass: {
prependData: "@import '@/styles/common.scss';",
},
},
},
// 全局变量配置
chainWebpack: (config) => {
// config.plugin("html").tap((args) => {
// args[0].title = title;
// return args;
// });
// if (process.env.NODE_ENV === "production") {
// //生产包取消console debugger打印
// config.optimization.minimizer("terser").tap((args) => {
// args[0].terserOptions.compress.drop_console = true;
// args[0].terserOptions.compress.drop_debugger = true;
// args[0].terserOptions.compress.pure_funcs = ["console.log"];
// args[0].terserOptions.output = {
// comments: false,
// };
// return args;
// });
// }
// 添加后缀拓展引入支持
config.resolve.extensions.add('.ts').add('.tsx');
config.module
.rule('ts')
.test(/\.(ts|tsx)$/)
.use('ts-loader')
.loader('ts-loader')
.options({
// 配置能够识别vue中的ts
appendTsSuffixTo: [/\.vue$/]
})
.end();
}
})