You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
838 B

4 weeks ago
  1. /**
  2. * Used to package and output gzip. Note that this does not work properly in Vite, the specific reason is still being investigated
  3. * https://github.com/anncwb/vite-plugin-compression
  4. */
  5. import compressPlugin from 'vite-plugin-compression'
  6. export function configCompressPlugin(
  7. compress,
  8. deleteOriginFile = false
  9. ) {
  10. const compressList = compress.split(',')
  11. const plugins = []
  12. if (compressList.includes('gzip')) {
  13. plugins.push(
  14. compressPlugin({
  15. ext: '.gz',
  16. deleteOriginFile
  17. })
  18. )
  19. }
  20. if (compressList.includes('brotli')) {
  21. plugins.push(
  22. compressPlugin({
  23. ext: '.br',
  24. algorithm: 'brotliCompress',
  25. deleteOriginFile
  26. })
  27. )
  28. }
  29. return plugins
  30. }