vue.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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://192.168.3.51:18086', // 测试环境
  36. target: 'http://124.71.68.31:50001',
  37. // target: 'http://192.168.1.100:18086', //朱
  38. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  39. pathRewrite: {
  40. '^/api': ''
  41. }
  42. }
  43. }
  44. },
  45. chainWebpack(config) {
  46. config.plugins.delete('prefetch');
  47. // set svg-sprite-loader
  48. // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
  49. // config.module
  50. // .rule('icons')
  51. // .test(/\.svg$/)
  52. // .include.add(resolve('./src/icons'))
  53. // .end()
  54. // .use('svg-sprite-loader')
  55. // .loader('svg-sprite-loader')
  56. // .options({
  57. // symbolId: 'icon-[name]'
  58. // })
  59. // .end();
  60. config.module.rule('svg').exclude.add(resolve('src/icons')).end();
  61. config.module
  62. .rule('icons')
  63. .test(/\.svg$/)
  64. .include.add(resolve('src/icons'))
  65. .end()
  66. .use('svg-sprite-loader')
  67. .loader('svg-sprite-loader')
  68. .options({
  69. symbolId: 'icon-[name]'
  70. })
  71. .end();
  72. if (process.env.NODE_ENV !== 'development') {
  73. // gzip 压缩
  74. config.plugin('compressionPlugin').use(
  75. new CompressionWebpackPlugin({
  76. test: /\.(js|css|html)$/,
  77. threshold: 10240
  78. })
  79. );
  80. }
  81. },
  82. css: {
  83. loaderOptions: {
  84. sass: {
  85. sassOptions: {
  86. outputStyle: 'expanded',
  87. importer: transformElementScss()
  88. }
  89. }
  90. }
  91. }
  92. };