astro-html-minifier-next 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -17
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/index.ts +3 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- **Improves page speed** - Reduces the size of HTML assets by removing everything unnecessary.
|
|
6
6
|
- **Highly configurable** - All options from [html-minifier-next][html-minifier-next] are supported and can be customized.
|
|
7
|
-
- **Fast** - Runs the minification of all assets with (limited) concurrency.
|
|
7
|
+
- **Fast** - Runs the minification of all assets with (limited) concurrency and [Lightning CSS][lightningcss].
|
|
8
8
|
|
|
9
9
|
[][latest-release]
|
|
10
10
|
[][package-on-npm]
|
|
@@ -29,7 +29,8 @@ export default defineConfig({
|
|
|
29
29
|
html5: true,
|
|
30
30
|
includeAutoGeneratedTags: true,
|
|
31
31
|
keepClosingSlash: false,
|
|
32
|
-
|
|
32
|
+
log: (msg) => { if (msg instanceof Error) throw msg },
|
|
33
|
+
minifyCSS: { errorRecovery: false },
|
|
33
34
|
minifyJS: true,
|
|
34
35
|
minifyURLs: false,
|
|
35
36
|
noNewlinesBeforeTagClose: false,
|
|
@@ -61,9 +62,9 @@ This will install the package and make the appropriate changes to your
|
|
|
61
62
|
```bash
|
|
62
63
|
npx astro add astro-html-minifier-next
|
|
63
64
|
```
|
|
64
|
-
If you prefer to
|
|
65
|
+
If you prefer to add the integration manually instead, complete the
|
|
65
66
|
following two steps:
|
|
66
|
-
1. Install the
|
|
67
|
+
1. Install the package to your project’s dependencies using your preferred
|
|
67
68
|
package manager.
|
|
68
69
|
If you’re using npm or aren’t sure, run this in the terminal:
|
|
69
70
|
```bash
|
|
@@ -82,13 +83,13 @@ following two steps:
|
|
|
82
83
|
|
|
83
84
|
export default defineConfig({
|
|
84
85
|
// ...
|
|
86
|
+
|
|
85
87
|
integrations: [
|
|
86
|
-
|
|
88
|
+
// ...
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
// ADD THE FOLLOWING LINE:
|
|
91
|
+
htmlMinifier({ /* Your html-minifier-next options here. */ }),
|
|
90
92
|
],
|
|
91
|
-
// ...
|
|
92
93
|
});
|
|
93
94
|
```
|
|
94
95
|
|
|
@@ -101,30 +102,68 @@ generated by Astro during the build process using the provided
|
|
|
101
102
|
### Options
|
|
102
103
|
|
|
103
104
|
You can find a quick reference of all available options in the
|
|
104
|
-
[html-minifier-next documentation][html-minifier-next-options].
|
|
105
|
+
[html-minifier-next documentation][html-minifier-next-options].
|
|
106
|
+
You can also check out the
|
|
107
|
+
[JSDoc comments in the source code][html-minifier-next-options-source].
|
|
105
108
|
|
|
106
109
|
> **Tip**
|
|
107
|
-
>
|
|
108
|
-
>
|
|
109
|
-
>
|
|
110
|
+
> To ensure consistent and wide browser support throughout your project,
|
|
111
|
+
> I recommend setting the `targets` property of the `minifyCSS` option to your
|
|
112
|
+
> project's [Browserslist][browserslist] query.
|
|
113
|
+
> This configures [Lightning CSS][lightningcss] (the CSS minifier used by
|
|
114
|
+
> [html-minifier-next][html-minifier-next]) to properly optimize the CSS
|
|
115
|
+
> according to the browsers you want to support.
|
|
116
|
+
>
|
|
117
|
+
> You can do this, by adding the following lines to your
|
|
118
|
+
> `astro.config.mjs`/`astro.config.ts` file:
|
|
119
|
+
> ```typescript
|
|
120
|
+
> import { defineConfig } from "astro/config";
|
|
121
|
+
> import htmlMinifier from "astro-html-minifier-next";
|
|
122
|
+
>
|
|
123
|
+
> // ADD THE FOLLOWING LINES:
|
|
124
|
+
> import browserslist from "browserslist";
|
|
125
|
+
> import { browserslistToTargets } from "lightningcss";
|
|
126
|
+
>
|
|
127
|
+
> export default defineConfig({
|
|
128
|
+
> // ...
|
|
129
|
+
>
|
|
130
|
+
> integrations: [
|
|
131
|
+
> // ...
|
|
132
|
+
>
|
|
133
|
+
> htmlMinifier({
|
|
134
|
+
> // ...
|
|
135
|
+
>
|
|
136
|
+
> minifyCSS: {
|
|
137
|
+
> // ...
|
|
138
|
+
>
|
|
139
|
+
> // ADD THE FOLLOWING LINE:
|
|
140
|
+
> targets: browserslistToTargets(browserslist("defaults")),
|
|
141
|
+
> },
|
|
142
|
+
> }),
|
|
143
|
+
> ],
|
|
144
|
+
> });
|
|
145
|
+
> ```
|
|
110
146
|
>
|
|
111
|
-
> More information can be found in the [
|
|
147
|
+
> More information can be found in the [Lightning CSS documentation][lightningcss-docs].
|
|
112
148
|
|
|
113
149
|
## Credits
|
|
114
150
|
|
|
115
151
|
This integration wouldn't be possible without the awesome work of
|
|
116
|
-
[Juriy Zaytsev
|
|
152
|
+
[Juriy Zaytsev aka. @kangax][@kangax] ([html-minifier][html-minifier]),
|
|
117
153
|
[the Terser team][@terser] ([html-minifier-terser][html-minifier-terser]), and
|
|
118
|
-
of course [Jens Oliver Meiert
|
|
154
|
+
of course [Jens Oliver Meiert aka. @j9t][@j9t] ([html-minifier-next][html-minifier-next]).
|
|
119
155
|
|
|
120
156
|
[astro]: https://astro.build/
|
|
121
157
|
[html-minifier-next]: https://www.npmjs.com/package/html-minifier-next
|
|
122
|
-
[html-minifier-next-options]: https://www.npmjs.com/package/html-minifier-next#
|
|
158
|
+
[html-minifier-next-options]: https://www.npmjs.com/package/html-minifier-next#options-quick-reference
|
|
159
|
+
[html-minifier-next-options-source]: https://github.com/j9t/html-minifier-next/blob/ba95daa75dfec6e3c6bb8bd1b0af3ad84e596e61/src/htmlminifier.js#L1482
|
|
123
160
|
[latest-release]: https://github.com/jonasgeiler/astro-html-minifier-next/releases/latest
|
|
124
161
|
[package-on-bundlejs]: https://bundlejs.com/?q=astro-html-minifier-next
|
|
125
162
|
[package-on-jsr]: https://jsr.io/@jonasgeiler/astro-html-minifier-next
|
|
126
163
|
[package-on-npm]: https://www.npmjs.com/package/astro-html-minifier-next
|
|
127
|
-
[
|
|
164
|
+
[browserslist]: https://browsersl.ist/
|
|
165
|
+
[lightningcss]: https://lightningcss.dev/
|
|
166
|
+
[lightningcss-docs]: https://lightningcss.dev/docs.html#with-vite
|
|
128
167
|
[@kangax]: https://github.com/kangax
|
|
129
168
|
[html-minifier]: https://github.com/kangax/html-minifier
|
|
130
169
|
[@terser]: https://github.com/terser
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AstroIntegration } from "astro";
|
|
2
2
|
import { type MinifierOptions as HTMLMinifierOptions } from "html-minifier-next";
|
|
3
|
+
export type { HTMLMinifierOptions };
|
|
3
4
|
/**
|
|
4
5
|
* An Astro integration that minifies HTML assets using
|
|
5
6
|
* [html-minifier-next](https://www.npmjs.com/package/html-minifier-next).
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACN,KAAK,eAAe,IAAI,mBAAmB,EAE3C,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACN,KAAK,eAAe,IAAI,mBAAmB,EAE3C,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CACnC,OAAO,CAAC,EAAE,mBAAmB,GAC3B,gBAAgB,CAyIlB"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,S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,SAAS,GAAG,IAAI;oBACf,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI;oBAC9B,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;gBACxC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,kBAAkB,iBAAiB,GAAG,CAAC,CAAC,CAAC;YACzE,CAAC;SACD;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-html-minifier-next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Minify Astro HTML assets using html-minifier-next!",
|
|
5
5
|
"homepage": "https://github.com/jonasgeiler/astro-html-minifier-next#readme",
|
|
6
6
|
"bugs": "https://github.com/jonasgeiler/astro-html-minifier-next/issues",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"astro": "^5.0.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"html-minifier-next": "^3.2.2"
|
|
21
|
+
"html-minifier-next": "^4.1.0"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@biomejs/biome": "2.3.2",
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
minify as minifyHTML,
|
|
10
10
|
} from "html-minifier-next";
|
|
11
11
|
|
|
12
|
+
// Re-export the HTMLMinifierOptions type for users who want to use it.
|
|
13
|
+
export type { HTMLMinifierOptions };
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* An Astro integration that minifies HTML assets using
|
|
14
17
|
* [html-minifier-next](https://www.npmjs.com/package/html-minifier-next).
|