// vue.config.js
const path = require('path');
const config = require('./src/config/server');
const DIST_PATH = path.resolve(__dirname, './dist');
const DEBUG = process.env.NODE_ENV === 'development';
module.exports = {
indexPath: DEBUG ? 'index.html' : 'index.ftl',
chainWebpack: config => {
config.plugin('html').tap(args => {
args[0].csrf =
'<meta name="_csrf" content="{{ctx.session.csrfToken}}"/><meta name="_csrf_header" content="X-CSRF-TOKEN"/>'
return args
})
config.module.rule('eslint').use('eslint-loader').loader('eslint-loader').tap(options => {
options.fix = true
return options
})
},
// publicPath: process.env.NODE_ENV === 'production' ? '/ctm01boss-web/' : '/',
publicPath: DEBUG ? '/' : `${config.apiPathPrefix}`,
outputDir: DIST_PATH,
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
transpileDependencies: [/@hui-pro/],
devServer: {
contentBase: DIST_PATH,
compress: false,
noInfo: true,
host: '0.0.0.0',
port: 8080,
overlay: {
warnings: false,
errors: true
},
// open: true, //配置自动启动浏览器
proxy: {
[`${config.baseContext}/*`]: {
target: config.target,
secure: false,
changeOrigin: true,
onProxyReq: (proxyReq, req, res) => {
if (config.isDev) {
proxyReq.setHeader('Cookie', config.Cookie)
}
}
}
}
}
};