vue.config.js 2.5 KB

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