一卡通系统管理平台前端界面

compression.ts 716B

1234567891011121314151617181920212223242526272829
  1. import compression from 'vite-plugin-compression';
  2. export default (env: any) => {
  3. const { VITE_BUILD_COMPRESS } = env;
  4. const plugin: any[] = [];
  5. if (VITE_BUILD_COMPRESS) {
  6. const compressList = VITE_BUILD_COMPRESS.split(',');
  7. if (compressList.includes('gzip')) {
  8. // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
  9. plugin.push(
  10. compression({
  11. ext: '.gz',
  12. deleteOriginFile: false
  13. })
  14. );
  15. }
  16. if (compressList.includes('brotli')) {
  17. plugin.push(
  18. compression({
  19. ext: '.br',
  20. algorithm: 'brotliCompress',
  21. deleteOriginFile: false
  22. })
  23. );
  24. }
  25. }
  26. return plugin;
  27. };