VUE`` 反向代理和打包配置文件 vue.config.js
const path = require('path')
module.exports = {
publicPath: './',
outputDir: 'dist',
lintOnSave: true,
runtimeCompiler: false,
productionSourceMap: false,
integrity: false,
chainWebpack: (config) => {
config.resolve.alias
.set('vue$', 'vue/dist/vue.esm.js')
.set('@', path.resolve(__dirname, './src'))
},
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
config.mode = 'production'
} else {
config.mode = 'development'
}
},
css: {
extract: true,
sourceMap: false,
loaderOptions: {},
modules: false
},
parallel: require('os').cpus().length > 1,
pwa: {},
devServer: {
open: true,
host: 'localhost',
port: 8080,
https: false,
hotOnly: false,
proxy: {
'/api': {
target: 'http://127.0.0.1:3000/api',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
before: (app) => {}
},
pluginOptions: {
}
}