vue.config.js 1.2 KB
// vue.config.js
const path = require('path')

module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV == 'development',
  productionSourceMap: false,
  devServer: {
    proxy: {
      '/compass': {
        target: 'https://testznzl.lgyzpt.com/',
        //target: 'https://hall.51xinpai.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/compass': 'compass'
        }
      }
    },
    host: '0.0.0.0',
    port: '8080',
    open: false
  },
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    devtool: 'source-map'
  },
  chainWebpack: config => {
    // 配置SVG图标
    config.module
      .rule('svg')
      .exclude.add(path.resolve(__dirname, 'src/icons'))
      .end()
    
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(path.resolve(__dirname, 'src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },
  css: {
    loaderOptions: {
      sass: {
        prependData: `@import "@/assets/styles/variables.scss";`
      }
    }
  }
}