Vue之vue.config.js配置文件

  1. 使用vue inspect > output.js可以查看到Vue脚手架的默认配置。
  2. 使用vue.config.js可以对脚手架进行个性化定制,详情见:https://cli.vuejs.org/zh

其中这个配置文件需要和package.json是同一级的:

 

 简单示例:

module.exports = {
  pages: {
    index: {
      //入口
      entry: 'src/main.js',
    },
  },
    lintOnSave:false, //关闭语法检查
    //开启代理服务器(方式一)
    /* devServer: {
    proxy: 'http://localhost:5000'
  }, */
    //开启代理服务器(方式二)
    devServer: {
    proxy: {
      '/atguigu': {
        target: 'http://localhost:5000',
                pathRewrite:{'^/atguigu':''},
        // ws: true, //用于支持websocket
        // changeOrigin: true //用于控制请求头中的host值
      },
      '/demo': {
        target: 'http://localhost:5001',
                pathRewrite:{'^/demo':''},
        // ws: true, //用于支持websocket
        // changeOrigin: true //用于控制请求头中的host值
      }
    }
  }
}

 

posted @ 2022-12-25 22:14  安静点--  阅读(617)  评论(0)    收藏  举报