vue.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const CompressionWebpackPlugin = require('compression-webpack-plugin'); // 开启压缩
  2. // const isProduction = process.env.NODE_ENV === 'production';
  3. module.exports = {
  4. publicPath: './',
  5. productionSourceMap: false,
  6. devServer: {
  7. port: 8081,
  8. proxy: {
  9. '/test/face': {
  10. target: 'https://facegame.platomix.net',
  11. pathRewrite: {
  12. '^/test/face': '/'
  13. }
  14. }
  15. }
  16. },
  17. chainWebpack: config => {
  18. config.plugins.delete('prefetch')
  19. },
  20. css: {
  21. loaderOptions: {
  22. css: {},
  23. postcss: {
  24. plugins: [
  25. require('postcss-plugin-px2rem')({
  26. rootValue: 75,
  27. exclude: /(node_module)/,
  28. }),
  29. ]
  30. },
  31. sass: {
  32. prependData: `@import "./src/styles/mixin.scss";`
  33. }
  34. }
  35. },
  36. configureWebpack: config => {
  37. const plugins = [];
  38. // 服务器也要相应开启gzip
  39. plugins.push(
  40. new CompressionWebpackPlugin({
  41. algorithm: 'gzip',
  42. test: /\.(js|css)$/, // 匹配文件名
  43. threshold: 10000, // 对超过10k的数据压缩
  44. deleteOriginalAssets: false, // 不删除源文件
  45. minRatio: 0.8 // 压缩比
  46. })
  47. )
  48. return {
  49. plugins
  50. }
  51. }
  52. }