vue.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * @Author: mlchen 374826075@qq.com
  3. * @Date: 2026-07-21 09:26:11
  4. * @LastEditors: mlchen 374826075@qq.com
  5. * @LastEditTime: 2026-07-27 09:31:32
  6. * @FilePath: /kd-aiot-frontend-wms/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: '/wms',
  18. lintOnSave: false,
  19. productionSourceMap: false,
  20. configureWebpack: {
  21. performance: {
  22. maxAssetSize: 2000000,
  23. maxEntrypointSize: 2000000
  24. },
  25. output: {
  26. // 把子应用打包成 umd 库格式
  27. library: {
  28. type: 'umd',
  29. name: `${name}`
  30. },
  31. chunkLoadingGlobal: `webpackJsonp_${name}`
  32. }
  33. },
  34. devServer: {
  35. // 代理跨域的配置
  36. proxy: {
  37. // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
  38. '/api': {
  39. // target: 'http://124.71.68.31:50001', // 测试环境
  40. // target: 'http://124.71.68.31:50001',
  41. // target: 'http://192.168.1.132:18086',
  42. // target: 'http://192.168.1.105:18086', //开发
  43. target: 'http://localhost:18086', //开发
  44. // target: 'http://192.168.1.251:18186', //测试
  45. // target: 'http://192.168.1.116:18086',
  46. // target: 'http://192.168.1.116:18086',
  47. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  48. pathRewrite: {
  49. '^/api': ''
  50. }
  51. }
  52. }
  53. },
  54. chainWebpack(config) {
  55. config.plugins.delete('prefetch');
  56. // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
  57. // config.module
  58. // .rule('icons')
  59. // .test(/\.svg$/)
  60. // .include.add(resolve('./src/icons'))
  61. // .end()
  62. // .use('svg-sprite-loader')
  63. // .loader('svg-sprite-loader')
  64. // .options({
  65. // symbolId: 'icon-[name]'
  66. // })
  67. // .end();
  68. config.module.rule('svg').exclude.add(resolve('src/icons')).end();
  69. config.module
  70. .rule('icons')
  71. .test(/\.svg$/)
  72. .include.add(resolve('src/icons'))
  73. .end()
  74. .use('svg-sprite-loader')
  75. .loader('svg-sprite-loader')
  76. .options({
  77. symbolId: 'icon-[name]'
  78. })
  79. .end();
  80. if (process.env.NODE_ENV !== 'development') {
  81. // gzip 压缩
  82. config.plugin('compressionPlugin').use(
  83. new CompressionWebpackPlugin({
  84. test: /\.(js|css|html)$/,
  85. threshold: 10240
  86. })
  87. );
  88. }
  89. },
  90. css: {
  91. loaderOptions: {
  92. sass: {
  93. sassOptions: {
  94. outputStyle: 'expanded',
  95. importer: transformElementScss()
  96. }
  97. }
  98. }
  99. }
  100. };