Skip to content

Commit

Permalink
rebse
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Jun 30, 2024
1 parent c0584f5 commit 1d785b2
Showing 1 changed file with 13 additions and 119 deletions.
132 changes: 13 additions & 119 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
<p align="center">
<img src="https://socialify.git.ci/nonzzz/vite-plugin-compression/image?description=1&font=KoHo&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F65625612%3Fs%3D200%26v%3D4&name=1&owner=1&pattern=Solid&theme=Auto" width="640" height="320" />
</p>
Expand All @@ -8,13 +7,11 @@
## Install

```bash

$ yarn add vite-plugin-compression2 -D

# or

$ npm install vite-plugin-compression2 -D

```

## Usage
Expand All @@ -34,16 +31,16 @@ export default defineConfig({

## Options

| params | type | default | description |
| ---------------------- | --------------------------------------------- | ----------------- | -------------------------------------------------------------- |
| `include` | `string \| RegExp \| Array<string \| RegExp>` | `/\.(html\|xml\|css\|json\|js\|mjs\|svg)$/` | Include all assets matching any of these conditions. |
| `exclude` | `string \| RegExp \| Array<string \| RegExp>` | `-` | Exclude all assets matching any of these conditions. |
| `threshold` | `number` | `0` | Only assets bigger than this size are processed (in bytes) |
| `algorithm` | `string\| function` | `gzip` | The compression algorithm |
| `compressionOptions` | `Record<string,any>` | `{}` | Compression options for `algorithm`(details see `zlib module`) |
| `deleteOriginalAssets` | `boolean` | `false` | Whether to delete the original assets or not |
| `skipIfLargerOrEqual` | `boolean` | `true` | Whether to skip the compression if the result is larger than or equal to the original file |
| `filename` | `string` | `[path][base].gz` | The target asset filename |
| params | type | default | description |
| ---------------------- | --------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `include` | `string \| RegExp \| Array<string \| RegExp>` | `/\.(html\|xml\|css\|json\|js\|mjs\|svg)$/` | Include all assets matching any of these conditions. |
| `exclude` | `string \| RegExp \| Array<string \| RegExp>` | `-` | Exclude all assets matching any of these conditions. |
| `threshold` | `number` | `0` | Only assets bigger than this size are processed (in bytes) |
| `algorithm` | `string\| function` | `gzip` | The compression algorithm |
| `compressionOptions` | `Record<string,any>` | `{}` | Compression options for `algorithm`(details see `zlib module`) |
| `deleteOriginalAssets` | `boolean` | `false` | Whether to delete the original assets or not |
| `skipIfLargerOrEqual` | `boolean` | `true` | Whether to skip the compression if the result is larger than or equal to the original file |
| `filename` | `string` | `[path][base].gz` | The target asset filename |

## Q & A

Expand Down Expand Up @@ -75,7 +72,9 @@ export default defineComponent({
```

> Can i create a tarball for all of assets after compressed?
- Yes, you can import `tarball` plugin from this package(>=1.0.0)

```js
import { defineComponent } from 'vite'
import { compression, tarball } from 'vite-plugin-compression2'
Expand All @@ -87,15 +86,13 @@ export default defineComponent({
tarball()
]
})

```

### Others

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

- `tarball` option `dest` means to generate a tarball somewhere

- `tarball` option `dest` means to generate a tarball somewhere

### LICENSE

Expand All @@ -104,106 +101,3 @@ export default defineComponent({
### Author

Kanno
=======
<p align="center">
<img src="https://socialify.git.ci/nonzzz/vite-plugin-compression/image?description=1&font=KoHo&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F65625612%3Fs%3D200%26v%3D4&name=1&owner=1&pattern=Solid&theme=Auto" width="640" height="320" />
</p>

[![codecov](https://codecov.io/gh/nonzzz/vite-plugin-compression/branch/master/graph/badge.svg?token=NG4475OP6B)](https://codecov.io/gh/nonzzz/vite-compression-plugin)

## Install

```bash
$ yarn add vite-plugin-compression2 -D

# or

$ npm install vite-plugin-compression2 -D
```

## Usage

```js
import { defineConfig } from 'vite'

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

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

## Options

| params | type | default | description |
| ---------------------- | --------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `include` | `string \| RegExp \| Array<string \| RegExp>` | `/\.(html\|xml\|css\|json\|js\|mjs\|svg)$/` | Include all assets matching any of these conditions. |
| `exclude` | `string \| RegExp \| Array<string \| RegExp>` | `-` | Exclude all assets matching any of these conditions. |
| `threshold` | `number` | `0` | Only assets bigger than this size are processed (in bytes) |
| `algorithm` | `string\| function` | `gzip` | The compression algorithm |
| `compressionOptions` | `Record<string,any>` | `{}` | Compression options for `algorithm`(details see `zlib module`) |
| `deleteOriginalAssets` | `boolean` | `false` | Whether to delete the original assets or not |
| `skipIfLargerOrEqual` | `boolean` | `true` | Whether to skip the compression if the result is larger than or equal to the original file |
| `filename` | `string` | `[path][base].gz` | The 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?
```js
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)

```js
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
>>>>>>> f4b702d (chore: init)

0 comments on commit 1d785b2

Please sign in to comment.