forked from nonzzz/vite-plugin-compression
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export type helper function and type optimization (nonzzz#59)
* feat: expose a define helper * chore: migrate to vitest * test: init type-check test * chore: fix ci * chore: fix patches * chore: fix workflow * chore: clean example * docs: morve faq * feat: add publish workflow * chore: fix type * chore: expose * chore: fmt * chore: fallback v20 --------- Co-authored-by: mengdaoshizhongxinyang <[email protected]>
- Loading branch information
1 parent
a0e477c
commit bf1f8ed
Showing
33 changed files
with
1,783 additions
and
2,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: publish | ||
on: | ||
push: | ||
tags: ['v*'] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install Berry | ||
run: corepack enable | ||
- name: Install Dependices | ||
run: yarn | ||
- name: Pack and Publish | ||
run: | | ||
yarn build | ||
npm publish --provenance --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
e2e/vite2/patches/vite+2.9.15.patch → .../patches/vite-npm-2.9.15-da673a6d8d.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
install: | ||
@echo "Setup yarn package manager..." | ||
@corepack enable | ||
yarn install | ||
|
||
build: | ||
@echo "Building..." | ||
@yarn exec rollup --config rollup.config.ts --configPlugin swc3 | ||
|
||
dev: | ||
@echo "Starting development server..." | ||
@yarn exec rollup --config rollup.config.ts --configPlugin swc3 --watch | ||
|
||
test: | ||
@echo "Running tests..." | ||
@yarn exec vitest --dir __tests__ --typecheck.enabled | ||
|
||
end-to-end-test: | ||
@echo "Running end-to-end tests..." | ||
@yarn exec vitest --dir e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Q & A | ||
|
||
> What is this plugin do? | ||
- It's a simple zlib binding for vite, No a code compressor or a mangle. It help you compress your bundle assets in your local machine to save your precious server memory. | ||
|
||
> How do i know if i need this plugin? | ||
- Normally, You won't need it for most scenes. Follow the previous answer we know we only using it to compress us bundle asset in client, | ||
So if some other clould server provider provide the smae server, you don't need it. | ||
|
||
> How can i use it? | ||
- There are two step. 1, install this plugin and add it into your vite config then build your application, upload your bundle assets to your server. | ||
2, Makesure you have already using `tomcat` or `nginx` or others proxy server and find the relevant configuration tutorial. Like nignix, you can refer | ||
[document](https://nginx.org/en/docs/http/ngx_http_gzip_module.html) | ||
|
||
> Why `vite-plugin-compression2` not `vite-plugin-compression`? | ||
- To be honest, It won't maintain anymore, So that i made a new one. | ||
|
||
> How can i define a custom compression algorithm? | ||
```ts | ||
|
||
import { defineCompressionOption } from 'vite-plugin-compression2' | ||
import { ZlibOption } from 'zlib' | ||
|
||
const opt = defineCompressionOption<ZlibOption>({ | ||
// ... | ||
}) | ||
|
||
``` | ||
|
||
> How can i generate multiple compressed assets with difference compression algorithm? | ||
```ts | ||
|
||
import { defineComponent } from 'vite' | ||
import { compression } from 'vite-plugin-compression2' | ||
|
||
export default defineComponent({ | ||
plugins: [ | ||
// ...your plugin | ||
compression(), | ||
compression({ algorithm: 'brotliCompress' }) | ||
] | ||
}) | ||
|
||
|
||
``` | ||
|
||
> Can `tarball` be used only? | ||
- Yes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.