vue.config.js配置

// 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 =
        ''
      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)
          }
        }
      }
    }
  }
};

 

你可能感兴趣的:(vue.config.js配置)