vue.config.js配置

// const path = require('path')

module.exports = {
    runtimeCompiler: true,
    devServer: {
        proxy: {
            '/mock': {
                target: 'https://easy-mock.com/mock/example',
                // ws: true,
                changeOrigin: true,
                pathRewrite: {//重写路径
                    "^/mock": ''
                }
            },
            '/api': {
              target: 'http://~',//测试
              // ws: true,
              changeOrigin: true,
              pathRewrite: {//重写路径
                  "^/api": ''
              }
            }
        }
    },
    pluginOptions: {
      'style-resources-loader': {
        patterns: [
          // main.js里全局引入css配置
          // path.resolve(__dirname, './src/styles/*.scss')
        ],
        preProcessor: 'scss'
      }
    },
    css: {
      // 向所有 Sass 样式传入共享的全局变量:
      loaderOptions: {
        // 给 sass-loader 传递选项
        sass: {
          // @/ 是 src/ 的别名
          // 所以这里假设你有 `src/variables.scss` 这个文件
          data: `@import "~@/styles/variables.scss";`
        }
      }
    }
}

猜你喜欢

转载自www.cnblogs.com/knuzy/p/11374480.html