配置生產環境加路徑 /開發環境
阿新 • • 發佈:2020-12-16
技術標籤:vue
let proxyObj = {}; const CompressionPlugin = require("compression-webpack-plugin"); proxyObj['/'] = { ws: false, target: 'http://192.168.10.110:8082', //target: 'http://localhost:8082', changeOrigin: true, pathRewrite: { '^/': '' } } module.exports = { //生產環境加路徑 publicPath: '/finance', outputDir: 'dist', //assetsDir: 'static', lintOnSave: process.env.NODE_ENV === 'development', devServer: { host: 'localhost', port: 8080, proxy: proxyObj }, configureWebpack: config => { if (process.env.NODE_ENV === 'production') { return { plugins: [ new CompressionPlugin({ test: /\.js$|\.html$|\.css/, threshold: 1024, deleteOriginalAssets: false }) ] } } } }