vue.config.js 1.4 KB
const { defineConfig } = require('@vue/cli-service')
const px2rem = require('postcss-px2rem')

console.log('---------------构建环境:' + process.env.VUE_APP_MODE + '------------------')

module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,

  chainWebpack: (config) => {
    config.plugin('html').tap(args => {
      args[0].title = '网页标题'; // 设置网页标题
      args[0].meta = {
        description: 'Your Description', // 设置网页描述
        keywords: 'keyword1, keyword2, keyword3' // 设置关键词
      };
      return args;
    });

    // px自动转化rem
    config.module
      .rule('scss')
      .test(/\.scss$/)
      .oneOf('vue')
      .resourceQuery(/\?vue/)
      .use('postcss-loader')
      .loader('postcss-loader')
      .tap((args) => {
        args.postcssOptions = {
          plugins: [
            px2rem({
              // 设计稿尺寸 / 10
              remUnit: 75
            })
          ]
        };
        return args;
      })
  },

  devServer: {
    open: true,
    // host: 'localhost',
    port: 8080,
    proxy: {
      "/report": {
        target: 'https://jdlog-test.uu.cc',
        changeOrigin: true,
        pathRewrite: {
          '^/report': ''
        }
      },
      "/dev-web-gateway": {
        target: 'http://dev-ms.ids111.com:10030/',
        changeOrigin: true
      }
    }
  }
})