美文网首页
VUE3.0+的webpack配置

VUE3.0+的webpack配置

作者: KC莲 | 来源:发表于2020-01-14 11:07 被阅读0次

新建vue.config.js文件

image.png

编写vue.config.js内容如下

const path = require('path');
const resolve = dir => path.join(__dirname, dir);

module.exports = {
  // 基本路径
  publicPath: './',
  // 输出文件目录
  outputDir: 'dist',
  // eslint-loader 是否在保存的时候检查
  lintOnSave: true,
  // webpack配置别名
  chainWebpack: (config)=>{
    config.resolve.alias
        .set('@', resolve('src'))
  },
  devServer: {
    // 本地ip地址
    host: '0.0.0.0',
    port: 2333
  },
  /* 使用代理 */
  proxy: {
    '/api': {
      /* 目标代理服务器地址 */
      target: 'http://192.168.1.126:8080/',
      /* 允许跨域 */
      changeOrigin: true,
      ws: true,
      pathRewrite: {
        '^/api': ''
      }
    }
  }
};

相关文章

网友评论

      本文标题:VUE3.0+的webpack配置

      本文链接:https://www.haomeiwen.com/subject/nswoactx.html