vue.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-09 11:07:58
  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. headers: {
  37. // 允许跨域访问子应用页面
  38. 'Access-Control-Allow-Origin': '*'
  39. },
  40. // 代理跨域的配置
  41. proxy: {
  42. // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
  43. '/api': {
  44. // target: 'http://192.168.1.251:18086', //开发
  45. target: 'http://localhost:18086', //开发 // 本地联调临时指向本机后端(2026-11-05,联调后还原)
  46. // target: 'http://192.168.1.251:18186', //测试
  47. // target: 'http://192.168.1.15:18086',//罗
  48. // target: 'http://192.168.1.144:18086',//付
  49. // target: 'http://192.168.1.10:18086', //付
  50. // target: 'http://aiot.zoomwin.com.cn:51001/api',
  51. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  52. pathRewrite: {
  53. '^/api': ''
  54. }
  55. }
  56. }
  57. },
  58. chainWebpack(config) {
  59. config.plugins.delete('prefetch');
  60. // set svg-sprite-loader
  61. // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
  62. // config.module
  63. // .rule('icons')
  64. // .test(/\.svg$/)
  65. // .include.add(resolve('./src/icons'))
  66. // .end()
  67. // .use('svg-sprite-loader')
  68. // .loader('svg-sprite-loader')
  69. // .options({
  70. // symbolId: 'icon-[name]'
  71. // })
  72. // .end();
  73. config.module.rule('svg').exclude.add(resolve('src/icons')).end();
  74. config.module
  75. .rule('icons')
  76. .test(/\.svg$/)
  77. .include.add(resolve('src/icons'))
  78. .end()
  79. .use('svg-sprite-loader')
  80. .loader('svg-sprite-loader')
  81. .options({
  82. symbolId: 'icon-[name]'
  83. })
  84. .end();
  85. if (process.env.NODE_ENV !== 'development') {
  86. // gzip 压缩
  87. config.plugin('compressionPlugin').use(
  88. new CompressionWebpackPlugin({
  89. test: /\.(js|css|html)$/,
  90. threshold: 10240
  91. })
  92. );
  93. }
  94. },
  95. css: {
  96. loaderOptions: {
  97. sass: {
  98. sassOptions: {
  99. outputStyle: 'expanded',
  100. importer: transformElementScss()
  101. }
  102. }
  103. }
  104. }
  105. };