美文网首页
vue 中vue.config.js配置参数

vue 中vue.config.js配置参数

作者: wxw_威 | 来源:发表于2022-05-09 16:16 被阅读0次

创建vue.config.js文件(vue-cli service 会自动识别此文件)

module.exports = {
  // publicPath 作用:需要在服务器中创建对应的文件夹(eg:production-sub-path),将打包的项目放在此文件夹下.
  publicPath: process.env.NODE_ENV === 'production' ? '/production-sub-path/' : '/'
  // npm run build输出文件目录
  outputDir: 'dist',
  // 放置生成的静态资源 (js、css、img、fonts) 的目录
  assetsDir: 'assets',
// 如果你不需要使用eslint,把lintOnSave设为false即可
  lintOnSave: false,  

  // webpack-dev-server 相关配置
  devServer: {
    compress: false,      // 代码是否压缩
    open: true,    //设置自动打开
    port: 8080,    //设置端口

     //设置代理、跨域
    proxy: {
      // 设置端口
      '/axios': {
      target: 'http://101.15.22.98',
      changeOrigin: true,        // 设置跨域
      secure: false,           //如果是http接口,需要配置该参数
      pathRewrite: {
        '^/axios': ''
      }
    }
  }
}

相关文章

网友评论

      本文标题:vue 中vue.config.js配置参数

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