vue.config.js常用配置

// vue.config.js 常用配置

const path = require('path')
function resolve(dir) {
     
  // 返回一个路径
  // __dirname: 找到当前项目的绝对路径, 也就是 vue_bilibili 拼接上后面的参数 dir
  return path.join(__dirname, dir)
}

module.exports = {
     
  // 基本路径, vue.cli 3.3以前请使用 baseUrl
  publicPath: '/',
  // 打包后 输出文件目录
  outputDir: 'dist',
  // 生产环境sourceMap
  productionSourceMap: true,
  // webpack-dev-server 相关配置
  devServer: {
     
    open: true,
    host: "localhost",
    port: 8081,
    https: false,
    //以上的ip和端口是我们本机的;下面为需要跨域的
    proxy: {
     
      //配置跨域
      "/api": {
     
        target: "https://api.qq.jsososo.com", //填写真实的后台接口
        ws: true,
        changOrigin: true, //允许跨域
        pathRewrite: {
     
          "^/api": "", //请求的时候使用这个api就可以
        },
      },
    },
  },
  // 配置别名
  configureWebpack: {
     
    resolve: {
     
      alias: {
     
        "@": resolve("src"),
        "views": resolve("src/views")
      }
    }
  },
  // 第三方插件配置
  pluginOptions: [
    // ...
  ]
}

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