vue.config.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * @Author: mlchen 374826075@qq.com
  3. * @Date: 2026-07-22 15:43:30
  4. * @LastEditors: mlchen 374826075@qq.com
  5. * @LastEditTime: 2026-11-19 17:00:39
  6. * @FilePath: /kd-aiot-frontend-eom/vue.config.js
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. const CompressionWebpackPlugin = require('compression-webpack-plugin');
  10. const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme');
  11. const path = require('path');
  12. const { name } = require('./package.json');
  13. function resolve(dir) {
  14. return path.join(__dirname, dir);
  15. }
  16. module.exports = {
  17. publicPath: '/eos',
  18. lintOnSave: false,
  19. outputDir: 'dist',
  20. productionSourceMap: false,
  21. configureWebpack: {
  22. performance: {
  23. maxAssetSize: 2000000,
  24. maxEntrypointSize: 2000000
  25. },
  26. output: {
  27. // 把子应用打包成 umd 库格式
  28. library: {
  29. type: 'umd',
  30. name: `${name}`
  31. },
  32. chunkLoadingGlobal: `webpackJsonp_${name}`
  33. }
  34. },
  35. devServer: {
  36. client: {
  37. overlay: {
  38. // 与 Vue CLI 默认值保持一致:编译警告不遮罩页面(第三方 vue-form-making 的
  39. // "possible exports unknown" 警告会刷屏),只展示真正的编译错误
  40. warnings: false,
  41. errors: true,
  42. // ResizeObserver 循环通知是浏览器/图表库的良性告警(ECharts 自适应时会触发),
  43. // webpack-dev-server 会把未捕获告警当作运行时错误弹出全屏遮罩,这里只过滤这一条
  44. runtimeErrors: (error) => {
  45. const message = (error && error.message) || '';
  46. return !/ResizeObserver loop (completed with undelivered notifications|limit exceeded)/.test(
  47. message
  48. );
  49. }
  50. }
  51. },
  52. headers: {
  53. // 允许跨域访问子应用页面
  54. 'Access-Control-Allow-Origin': '*'
  55. },
  56. // 代理跨域的配置
  57. proxy: {
  58. // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
  59. '/api': {
  60. // target: 'http://192.168.1.251:18086', //开发
  61. // target: 'http://localhost:18086', //开发 // 本地联调临时指向本机后端(2026-11-05,联调后还原)
  62. // target: 'http://192.168.1.251:18186', //测试
  63. // target: 'http://192.168.1.15:18086',//罗
  64. // target: 'http://192.168.1.144:18086',//付
  65. // target: 'http://192.168.1.9:18086', //c
  66. target: 'https://aiot.zoomwin.com.cn:51001/api',
  67. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  68. pathRewrite: {
  69. '^/api': ''
  70. }
  71. }
  72. }
  73. },
  74. chainWebpack(config) {
  75. config.plugins.delete('prefetch');
  76. // set svg-sprite-loader
  77. // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
  78. // config.module
  79. // .rule('icons')
  80. // .test(/\.svg$/)
  81. // .include.add(resolve('./src/icons'))
  82. // .end()
  83. // .use('svg-sprite-loader')
  84. // .loader('svg-sprite-loader')
  85. // .options({
  86. // symbolId: 'icon-[name]'
  87. // })
  88. // .end();
  89. config.module.rule('svg').exclude.add(resolve('src/icons')).end();
  90. config.module
  91. .rule('icons')
  92. .test(/\.svg$/)
  93. .include.add(resolve('src/icons'))
  94. .end()
  95. .use('svg-sprite-loader')
  96. .loader('svg-sprite-loader')
  97. .options({
  98. symbolId: 'icon-[name]'
  99. })
  100. .end();
  101. if (process.env.NODE_ENV !== 'development') {
  102. // gzip 压缩
  103. config.plugin('compressionPlugin').use(
  104. new CompressionWebpackPlugin({
  105. test: /\.(js|css|html)$/,
  106. threshold: 10240
  107. })
  108. );
  109. }
  110. },
  111. css: {
  112. loaderOptions: {
  113. sass: {
  114. sassOptions: {
  115. outputStyle: 'expanded',
  116. importer: transformElementScss()
  117. }
  118. }
  119. }
  120. }
  121. };