vue.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. const CompressionWebpackPlugin = require('compression-webpack-plugin');
  2. const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme');
  3. module.exports = {
  4. lintOnSave: false,
  5. productionSourceMap: false,
  6. configureWebpack: {
  7. performance: {
  8. maxAssetSize: 2000000,
  9. maxEntrypointSize: 2000000
  10. }
  11. },
  12. devServer: {
  13. // 代理跨域的配置
  14. proxy: {
  15. // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
  16. '/api': {
  17. // target: 'http://192.168.3.51:86', // 测试
  18. //#gitignoreline_start
  19. //#gitignoreline_end
  20. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  21. pathRewrite: {
  22. '^/api': ''
  23. }
  24. }
  25. }
  26. },
  27. chainWebpack (config) {
  28. config.plugins.delete('prefetch');
  29. if (process.env.NODE_ENV !== 'development') {
  30. // gzip 压缩
  31. config.plugin('compressionPlugin').use(
  32. new CompressionWebpackPlugin({
  33. test: /\.(js|css|html)$/,
  34. threshold: 10240
  35. })
  36. );
  37. }
  38. },
  39. css: {
  40. loaderOptions: {
  41. sass: {
  42. sassOptions: {
  43. outputStyle: 'expanded',
  44. importer: transformElementScss()
  45. }
  46. }
  47. }
  48. }
  49. };