//此文件是用來配置開發環境和生產環境的配置參數
'use strict'//嚴格模式
const path = require('path')//node的path模塊 用來統一路徑
module.exports = {
dev:{//開發環境
//定義靜態資源根目錄的子目錄static
assetsSubDirectory:'static',
//靜態資源的公開路徑
assetsPublicPath:'',
//代理表,用來建一個虛擬api服務器來代理本機的請求,只用於開發模式
proxyTable:{
//下面是例子
"/api":{
//設置調用的接口域名和端口
target:"http://123.45.678.123/api/user",
//可跨域
changeOrigin:true,
pathRewrite:{
"^api":""//用/api代替http://123.45.678.123/api/user
}
}
},
//主機
host:'localhost',
//域名
port:8080,
//是否在瀏覽器中自動打開
autoOpenBrowser:false,
//是否查詢錯誤
errorOverlay:true,
//是否通知錯誤
notifyOnErrors:true,
poll:false,
//開發工具,不每個模塊使用 eval() 執行,並且 SourceMap 轉換爲 DataUrl 後添加到 eval() 中。"低開銷"是因爲它沒有生成列映射(column map),只是映射行數,作用是當js拋出異常時,顯示報錯的是第幾行
devtool:'cheap-module-eval-source-map',
//是否緩存破壞
cacheBusting:true,
//記錄壓縮的代碼,用來找到源碼位置
cssSourceMap:true
},
build:{//生產環境
//編譯輸入的index.html文件,path.resolve(__dirname,'')是獲取其完整的絕對路徑
index:path.resolve(__dirname,'../dist/index.html'),
//編譯輸出的靜態資源路徑
assetsRoot:path.resolve(__dirname,'../dist'),
//編譯輸出的靜態資源路徑的子目錄
assetsSubDirectory:'static',
//編譯輸出的根目錄
assetsPublicPath:'/',
//是否開啓sourceMap
productionSourceMap:true,
//開發工具 用來調試
devtool:'#source-map',
//是否開啓gzip壓縮
productionGzip:false,
//使用gzip壓縮的文件擴展名
productionGzipExtensions:['js','css'],
//性能優化 打包文件分析工具 process是node.js的進程的有關信息以及控制進程
bundleAnalyzerReport:process.env.npm_config_report
}
}
轉載地址:https://blog.csdn.net/xiaoxiaoluckylucky/article/details/85859572