1.1.0 • Published 23 days ago

vite-plugin-compression2 v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

codecov

Install

$ yarn add vite-plugin-compression2 -D

# or

$ npm install vite-plugin-compression2 -D

Usage

import { defineConfig } from 'vite'

import { compression } from 'vite-plugin-compression2'

export default defineConfig({
  plugins: [
    // ...your plugin
    compression()
  ]
})

Options

paramstypedefaultdescription
includestring \| RegExp \| Array<string \| RegExp>/\.(html\|xml\|css\|json\|js\|mjs\|svg)$/Include all assets matching any of these conditions.
excludestring \| RegExp \| Array<string \| RegExp>-Exclude all assets matching any of these conditions.
thresholdnumber0Only assets bigger than this size are processed (in bytes)
algorithmstring\| functiongzipThe compression algorithm
compressionOptionsRecord<string,any>{}Compression options for algorithm(details see zlib module)
deleteOriginalAssetsbooleanfalseWhether to delete the original assets or not
skipIfLargerOrEqualbooleantrueWhether to skip the compression if the result is larger than or equal to the original file
filenamestring[path][base].gzThe target asset filename

Q & A

Why not vite-plugin-compression

  • vite-plugin-compression no longer maintenance.

Why vite-plugin-compression2

  • vite-plugin-compression2 has minimal dependencies and better performance.

Can i custom the compression algorithm?

  • Yes, you can see the unit test case.

Can i generate multiple compressed assets with difference compression algorithm?

import { defineComponent } from 'vite'
import { compression } from 'vite-plugin-compression2'

export default defineComponent({
  plugins: [
    // ...your plugin
    compression(),
    compression({ algorithm: 'brotliCompress' })
  ]
})

Can i create a tarball for all of assets after compressed?

  • Yes, you can import tarball plugin from this package(>=1.0.0)
import { defineComponent } from 'vite'
import { compression, tarball } from 'vite-plugin-compression2'

export default defineComponent({ plugins: // ...your plugin compression(), tarball() })

### Others

If you want to analysis your bundle assets. Maybe you can try [vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)

### LICENSE

[MIT](./LICENSE)

### Author

Kanno
1.1.0

23 days ago

1.0.0

2 months ago

0.12.0

3 months ago

0.11.0

7 months ago

0.10.6

7 months ago

0.9.3

11 months ago

0.10.1

11 months ago

0.10.2

10 months ago

0.10.3

10 months ago

0.10.4

9 months ago

0.10.5

8 months ago

0.10.0

11 months ago

0.9.2

11 months ago

0.8.4

1 year ago

0.9.0

1 year ago

0.8.1

1 year ago

0.6.3

1 year ago

0.8.0

1 year ago

0.6.2

1 year ago

0.8.3

1 year ago

0.9.1

1 year ago

0.8.2

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

2 years ago

0.1.0

2 years ago