vue.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // target: 'http://192.168.3.35:8080', // kang杨威
  19. target: 'http://192.168.3.31:8080', // 黄峥嵘
  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. };