vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const CompressionPlugin = require("compression-webpack-plugin");
  2. module.exports = {
  3. // publicPath: process.env.NODE_ENV === 'production'
  4. // ? '/infoVue/'
  5. // : '/',
  6. publicPath:'./',
  7. // outputDir: 'dist',
  8. // assetsDir: 'static',
  9. productionSourceMap:false,
  10. configureWebpack: () => {
  11. if (process.env.NODE_ENV === 'production') {
  12. return {
  13. plugins: [
  14. new CompressionPlugin({
  15. test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/, // 需要压缩的文件类型
  16. threshold: 10240, // 归档需要进行压缩的文件大小最小值,我这个是10K以上的进行压缩
  17. deleteOriginalAssets: false // 是否删除原文件
  18. })
  19. ]
  20. }
  21. }
  22. },
  23. // 配置反向代理
  24. devServer: {
  25. https: true,
  26. proxy:{
  27. "/collection": {
  28. // target: "http://127.0.0.1:7001", // 生产后端路径
  29. // target: "https://mz.tshe.cn/collection", // 生产后端路径
  30. target: "https://info.windd.cn/collection", // 生产后端路径
  31. ws: true, // 是否启用websockets
  32. changeOrigin: true, //开启代理:在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
  33. pathRewrite: {
  34. "^/collection": "" //这里理解成用'/api'代替target里面的地址,比如我要调用'http://40.00.100.100:3002/user/add',直接写'/api/user/add'即可
  35. }
  36. },
  37. },
  38. }
  39. };