astro-compressor
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -0,2 +1,18 @@ | ||
## v0.3.0 | ||
> 2023-01-31 | ||
## Summary | ||
Add configuration options to integration, bump Astro dependency to 2.0. | ||
### Commits | ||
- [[`bf612b4`](https://github.com/sondr3/astro-compressor)] Add configuration to README | ||
- [[`230e092`](https://github.com/sondr3/astro-compressor)] Bump packages | ||
- [[`3472d07`](https://github.com/sondr3/astro-compressor)] Allow enabling/disabling gzip and brotli compression | ||
- [[`711a36f`](https://github.com/sondr3/astro-compressor)] Prefix url with `node:` | ||
## v0.2.2 | ||
> 2022-12-29 | ||
@@ -9,2 +25,3 @@ | ||
### Commits | ||
- [[`d9d04eb`](https://github.com/sondr3/astro-compressor)] Use fileUrlToPath to fix path on Windows | ||
@@ -16,2 +33,3 @@ - [[`cef27ed`](https://github.com/sondr3/astro-compressor)] Don't force height on badge | ||
## v0.2.1 | ||
> 2022-12-29 | ||
@@ -24,2 +42,3 @@ | ||
### Commits | ||
- [[`fc44e2a`](https://github.com/sondr3/astro-compressor)] Use extname to get file extension | ||
@@ -29,2 +48,3 @@ - [[`341fd5c`](https://github.com/sondr3/astro-compressor)] Change m -> ms | ||
## v0.2.0 | ||
> 2022-12-29 | ||
@@ -37,5 +57,7 @@ | ||
### Commits | ||
- [[`f0840e5`](https://github.com/sondr3/astro-compressor)] Remove globby dependency, use stdlib | ||
## v0.1.3 | ||
> 2022-12-27 | ||
@@ -48,2 +70,3 @@ | ||
### Commits | ||
- [[`28b0d90`](https://github.com/sondr3/astro-compressor)] Fix release CI step | ||
@@ -50,0 +73,0 @@ - [[`acc0b18`](https://github.com/sondr3/astro-compressor)] Update dependencies, fix formatting |
@@ -1,3 +0,3 @@ | ||
export declare const gzip: (dir: string) => Promise<void>; | ||
export declare const brotli: (dir: string) => Promise<void>; | ||
export declare const gzip: (dir: string, enabled?: boolean) => Promise<void>; | ||
export declare const brotli: (dir: string, enabled?: boolean) => Promise<void>; | ||
//# sourceMappingURL=compress.d.ts.map |
@@ -23,3 +23,7 @@ import { createReadStream, createWriteStream } from "node:fs"; | ||
}; | ||
export const gzip = async (dir) => { | ||
export const gzip = async (dir, enabled) => { | ||
if (!enabled) { | ||
Logger.warn("gzip compression disabled, skipping..."); | ||
return; | ||
} | ||
const start = hrtime.bigint(); | ||
@@ -37,3 +41,7 @@ let counter = 0; | ||
}; | ||
export const brotli = async (dir) => { | ||
export const brotli = async (dir, enabled) => { | ||
if (!enabled) { | ||
Logger.warn("brotli compression disabled, skipping..."); | ||
return; | ||
} | ||
const start = hrtime.bigint(); | ||
@@ -40,0 +48,0 @@ let counter = 0; |
import type { AstroIntegration } from "astro"; | ||
export declare const createCompressionPlugin: () => AstroIntegration; | ||
export default createCompressionPlugin; | ||
interface Options { | ||
gzip?: boolean; | ||
brotli?: boolean; | ||
} | ||
export default function (opts?: Options): AstroIntegration; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,5 +0,11 @@ | ||
import { fileURLToPath } from "url"; | ||
import { fileURLToPath } from "node:url"; | ||
import { brotli, gzip } from "./compress.js"; | ||
import { Logger } from "./logger.js"; | ||
export const createCompressionPlugin = () => { | ||
const defaultOptions = { | ||
gzip: true, | ||
brotli: true, | ||
}; | ||
// eslint-disable-next-line import/no-default-export | ||
export default function (opts = defaultOptions) { | ||
const options = { ...defaultOptions, ...opts }; | ||
return { | ||
@@ -10,3 +16,3 @@ name: "astro-compressor", | ||
const path = fileURLToPath(dir); | ||
await Promise.allSettled([gzip(path), brotli(path)]); | ||
await Promise.allSettled([gzip(path, options.gzip), brotli(path, options.brotli)]); | ||
Logger.success("Compression finished\n"); | ||
@@ -16,5 +22,3 @@ }, | ||
}; | ||
}; | ||
// eslint-disable-next-line import/no-default-export | ||
export default createCompressionPlugin; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "astro-compressor", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "A gzip and brotli compressor for Astro", | ||
@@ -35,15 +35,15 @@ "type": "module", | ||
"@types/node": "18.11.18", | ||
"@typescript-eslint/eslint-plugin": "5.47.1", | ||
"@typescript-eslint/parser": "5.47.1", | ||
"astro": "1.7.2", | ||
"eslint": "8.30.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"@typescript-eslint/eslint-plugin": "5.50.0", | ||
"@typescript-eslint/parser": "5.50.0", | ||
"astro": "2.0.4", | ||
"eslint": "8.33.0", | ||
"eslint-config-prettier": "8.6.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-simple-import-sort": "8.0.0", | ||
"eslint-plugin-simple-import-sort": "10.0.0", | ||
"eslint-plugin-tsdoc": "0.2.17", | ||
"prettier": "2.8.1", | ||
"prettier": "2.8.3", | ||
"prettier-eslint": "15.0.1", | ||
"typescript": "4.9.4" | ||
"typescript": "4.9.5" | ||
}, | ||
@@ -50,0 +50,0 @@ "scripts": { |
@@ -23,2 +23,3 @@ <h1 align="center">astro-compressor</h1> | ||
- [Usage](#usage) | ||
- [Configuration](#configuration) | ||
- [License](#license) | ||
@@ -62,4 +63,19 @@ </details> | ||
## Configuration | ||
You can also optionally enable and/or disable either the gzip or brotli compression by | ||
passing an options object to the compressor: | ||
```js | ||
import { defineConfig } from "astro/config"; | ||
import compressor from "astro-compressor"; | ||
export default defineConfig({ | ||
// ... | ||
integrations: [..., compressor({ gzip: true, brotli: false })], | ||
}); | ||
``` | ||
# License | ||
MIT. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17128
17
139
80