vue.config配置

104 阅读1分钟
module.exports = {
  css: {
    extract:false,// css分离 生产环境 true,开发环境 false
    modules: true, // 开启css模块化
    loaderOptions:{// 重写loader
      css: {
        // 选项会传递到css-loader
      },
      postcss: {
        // 选项会传递给 postcss-loader
      }
    }
  },
  devServer:{// 开发环境设置
    // host: '0.0.0.0',// IP地址地址
    port: 8003,// 端口
    open: true,// 开浏览器
    // https: false,
    proxy:{ // 代理
        '/api':{// 以/api开头即为target + /api  
          target:'https://xxx.com',
          changeOrigin:true,// 创建虚拟服务器 
          ws:true,// websocket代理,
          pathRewrite:{//路径替换
            '^/api':'',// axios 访问/api/v2 == target + /v2
          }
        }
      }
  },
  lintOnSave:false, //关闭esling警告
  lintOnSave: process.env.NODE_ENV !== 'production', //生产构建时禁用
  productionSourceMap:false, //打包map文件
}