vue.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * @Author: mlchen 374826075@qq.com
  3. * @Date: 2026-07-22 15:43:30
  4. * @LastEditors: mlchen 374826075@qq.com
  5. * @LastEditTime: 2026-07-27 09:31:46
  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://localhost:18086', //开发
  45. target: 'http://192.168.1.18:18086', //测试
  46. // target: 'http://192.168.1.15:18086',//罗
  47. // target: 'http://192.168.1.144:18086',//付
  48. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  49. pathRewrite: {
  50. '^/api': ''
  51. }
  52. }
  53. }
  54. },
  55. chainWebpack(config) {
  56. config.plugins.delete('prefetch');
  57. // set svg-sprite-loader
  58. // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
  59. // config.module
  60. // .rule('icons')
  61. // .test(/\.svg$/)
  62. // .include.add(resolve('./src/icons'))
  63. // .end()
  64. // .use('svg-sprite-loader')
  65. // .loader('svg-sprite-loader')
  66. // .options({
  67. // symbolId: 'icon-[name]'
  68. // })
  69. // .end();
  70. config.module.rule('svg').exclude.add(resolve('src/icons')).end();
  71. config.module
  72. .rule('icons')
  73. .test(/\.svg$/)
  74. .include.add(resolve('src/icons'))
  75. .end()
  76. .use('svg-sprite-loader')
  77. .loader('svg-sprite-loader')
  78. .options({
  79. symbolId: 'icon-[name]'
  80. })
  81. .end();
  82. if (process.env.NODE_ENV !== 'development') {
  83. // gzip 压缩
  84. config.plugin('compressionPlugin').use(
  85. new CompressionWebpackPlugin({
  86. test: /\.(js|css|html)$/,
  87. threshold: 10240
  88. })
  89. );
  90. }
  91. },
  92. css: {
  93. loaderOptions: {
  94. sass: {
  95. sassOptions: {
  96. outputStyle: 'expanded',
  97. importer: transformElementScss()
  98. }
  99. }
  100. }
  101. }
  102. };