vue.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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:18086', // 跨域请求的地址
  18. changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
  19. pathRewrite: {
  20. '^/api': ''
  21. }
  22. }
  23. }
  24. },
  25. chainWebpack(config) {
  26. config.plugins.delete('prefetch');
  27. if (process.env.NODE_ENV !== 'development') {
  28. // gzip 压缩
  29. config.plugin('compressionPlugin').use(
  30. new CompressionWebpackPlugin({
  31. test: /\.(js|css|html)$/,
  32. threshold: 10240
  33. })
  34. );
  35. }
  36. },
  37. css: {
  38. loaderOptions: {
  39. sass: {
  40. sassOptions: {
  41. outputStyle: 'expanded',
  42. importer: transformElementScss()
  43. }
  44. }
  45. }
  46. }
  47. };