module.exports = { publicPath: process.env.NODE_ENV === "production" ? "./" : "./", // 部署應用時的根路徑(默認'/'),也可用相對路徑(存在使用限制) outputDir: "dist", // 運行時生成的生產環境構建文件的目錄(默認''dist'',構建之前會被清除) assetsDir: "static", //放置生成的靜態資源(s、css、img、fonts)的(相對於 outputDir 的)目錄(默認'') lintOnSave: true, // 是否開啟eslint保存檢測 productionSourceMap: false, // 是否在構建生產包時生成sourcdeMap devServer: { /* 本地ip地址 */ host: "localhost", port: "80", hot: true, /* 自動打開瀏覽器 */ open: false, overlay: { warning: false, error: true },// 錯誤、警告在頁面彈出 /* 跨域代理 */ proxy: { "/api": { /* 目標代理服務器地址 */ target: "http://localhost:8080", // /* 允許跨域 */ changeOrigin: true, ws: true, pathRewrite: { "^/api": "" } }//, // '/foo': { // target: '<other_url>' // } }, // pluginOptions: {// 第三方插件配置 // // } } };
注意:該文件內部不可存在無效配置,如上面的 pluginOptions: { } ,內部如果沒有任何東西需要去掉,或者注釋,否則啟動、打包出錯。
