module.exports = {
devServer: {
host: '',
hot: true,
port: 8086,
disableHostCheck: true,//新版的webpack-dev-server出于安全考虑,默认检查hostname,
//如果hostname不是配置内的,将中断访问。
https: false, //如果是https代理的话,这个要打开的
open: true, // 是否在开启服务器后自动打开浏览器访问该服务器
proxy: {
'/prod-api': {
target: 'http://10.20.1.158', //要跨域的地址
changeOrigin: true, //是否开启跨域
},
'/api': {
target: 'http://192.168.2.28:8106',
changeOrigin: true,
// pathRewrite: {'^/get': ''} //路径重写
},
headers: {
Referer: 'https://127.0.0.1:8443'
} //使用https代理
}
},
lintOnSave: false, // lint语法检测关闭语法检查,主要针对ESlint里面定义却没有使用出现的报错
outputDir:"dist", // build打包输出目录
assetsDir:"static", // 静态文件输出目录,基于dist
indexPath: "index.html", // 输出html文件名
productionSourceMap: false, // 取消.map文件的打包,加快打包速度
publicPath:"./", //部署应用包时的基本 URL,//这个值也可以被设置为空字符串 ('') 或是相对路径 ('./'),
//这样所有的资源都会被链接为相对路径,这样打出来的包可以被部署在任意路径。
configureWebpack: (config) => {
// process.env为环境变量,分别对应.env.development文件和.env.production文件 此处表示加快开发环境打包速度
if (process.env.NODE_ENV !== 'production') return;
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true; //生产环境去掉console.log
return { // 此处配置webpack.config.js的相关配置
plugins: [],
performance: {},
};
},
}