Newer
Older
XinYang_SanWei+RongYun / vue.config.js
@张强云笔记本 张强云笔记本 on 23 Dec 2021 4 KB 11
/**
 * *@2020-04-06
 * *@author zhangQiangYun
 * *@describe vue-cli 3.x配置文件
 */
module.exports = {
  publicPath: '/', // 部署应用时的根路径(默认'/'),也可用相对路径(存在使用限制)
  outputDir: 'dist', // 运行时生成的生产环境构建文件的目录(默认''dist'',构建之前会被清除)
  assetsDir: 'static', // 放置生成的静态资源(s、css、img、fonts)的(相对于 outputDir 的)目录(默认'')
  indexPath: 'index.html', // 指定生成的 index.html 的输出路径(相对于 outputDir)也可以是一个绝对路径。
  pages: { // pages 里配置的路径和文件名在你的文档目录必须存在 否则启动服务会报错
    index: { // 除了 entry 之外都是可选的
      entry: 'src/main.js', // page 的入口,每个“page”应该有一个对应的 JavaScript 入口文件
      template: 'public/index.html', // 模板来源
      filename: 'index.html', // 在 dist/index.html 的输出
      title: '--', // 当使用 title 选项时,在 template 中使用:<title><%= htmlWebpackPlugin.options.title %></title>
      chunks: ['chunk-vendors', 'chunk-common', 'index'] // 在这个页面中包含的块,默认情况下会包含,提取出来的通用 chunk 和 vendor chunk
    },
    subpage: 'src/main.js' // 官方解释:当使用只有入口的字符串格式时,模板会被推导为'public/subpage.html',若找不到就回退到'public/index.html',输出文件名会被推导为'subpage.html'
  },
  lintOnSave: false, // 是否在保存的时候检查
  productionSourceMap: true, // 生产环境是否生成 sourceMap 文件
  css: {
    // extract: true,// 是否使用css分离插件 ExtractTextPlugin
    sourceMap: false, // 开启 CSS source maps
    loaderOptions: {}, // css预设器配置项
    modules: false // 启用 CSS modules for all css / pre-processor files.
  },
  devServer: { // 环境配置
    host: 'localhost',
    port: 8080,
    https: false,
    hotOnly: false,
    open: true, // 配置自动启动浏览器
    proxy: { // 配置多个代理(配置一个 proxy: 'http://localhost:4000' )
      '/api': {
        target: 'http://localhost:9929',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '' //需要rewrite重写的,
        }
      },
      '/gltfUrl': {
        // 历史数据
        //target: 'https://36.133.215.233:9999',
        // target: 'http://192.168.31.15:6081',
        target: 'http://192.168.100.18:10001', // 接口域名
        changeOrigin: true, //是否跨域
        pathRewrite: {
          '^/gltfUrl': '' //需要rewrite重写的,
        }
      },
      "/supermap3Dapi": {
        //target: "http://192.168.100.21:8090", //饶先选
        target: "http://192.168.100.6:8090", //饶先选
        changeOrigin: true,
        pathRewrite: {
          "^/supermap3Dapi": "" // 需要rewrite重写的,
        }
      },
      "/webstUrl": {
        target: "https://webst02.is.autonavi.com", // 接口域名 zhanghongzhi
        // 'target': 'http://132.232.115.20:8314', // 接口域名
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/webstUrl": "" //需要rewrite重写的,
        }
      },
      "/shiliangtuUrl": {
        //target: 'http://192.168.16.144:6081',
        target: 'http://192.168.100.18:10000',
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/shiliangtuUrl": "" //需要rewrite重写的,
        }
      },
      "/imgUrl": {
        // target: 'http://192.168.16.144:6081',
        target: 'http://192.168.100.18:10000',
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/imgUrl": "" //需要rewrite重写的,
        }
      },
      "/sysApi": {
        // target: "http://192.168.20.112:12000",
        target: "http://192.168.1.107:12000",
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/sysApi": "" //需要rewrite重写的,
        }
      },
      "/hapi": {
        // target: "http://192.168.20.112:12000",
        target: "http://192.168.1.107:12002",
        changeOrigin: true, //是否跨域
        pathRewrite: {
          "^/hapi": "" //需要rewrite重写的,
        }
      }



    }
  },
  pluginOptions: { // 第三方插件配置
    // ...
  },
  chainWebpack: config => {
    // 修复HMR
    config.resolve.symlinks(true)
  }
}