astro-html-minifier-next 0.2.1 → 1.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.
Files changed (2) hide show
  1. package/README.md +129 -3
  2. package/package.json +17 -2
package/README.md CHANGED
@@ -1,6 +1,132 @@
1
1
  # astro-html-minifier-next
2
2
 
3
- > Astro integration for [html-minifier-next](https://www.npmjs.com/package/html-minifier-next)
3
+ > Minify [Astro][astro] HTML assets using [html-minifier-next][html-minifier-next]!
4
4
 
5
- Work in progress - Not yet production ready and might introduce many breaking changes!!!
6
- Please wait for the v1.0.0 release!
5
+ - **Improves page speed** - Reduces the size of HTML assets by removing everything unnecessary.
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.
8
+
9
+ [![Version badge](https://img.shields.io/npm/v/astro-html-minifier-next?style=for-the-badge&label=Version&labelColor=2a2d35&color=f2ebf4)][latest-release]
10
+ [![NPM downloads badge](https://img.shields.io/npm/d18m/astro-html-minifier-next?style=for-the-badge&label=NPM%20Downloads&labelColor=2a2d35&color=e13fa0&cacheSeconds=86400)][package-on-npm]
11
+ [![JSR score badge](https://jsr.io/badges/@jonasgeiler/astro-html-minifier-next/score?style=for-the-badge&label=Score&logoColor=fff&labelColor=2a2d35&color=f2ebf4&cacheSeconds=86400)][package-on-jsr]
12
+ [![Minified size (gzip) badge](https://img.shields.io/bundlejs/size/astro-html-minifier-next?style=for-the-badge&labelColor=2a2d35&color=e13fa0&cacheSeconds=86400)][package-on-bundlejs]
13
+
14
+ ```typescript
15
+ import { defineConfig } from "astro/config";
16
+ import htmlMinifier from "astro-html-minifier-next";
17
+
18
+ export default defineConfig({
19
+ integrations: [
20
+ htmlMinifier({
21
+ /* My recommended html-minifier-next options: */
22
+ caseSensitive: true,
23
+ collapseBooleanAttributes: true,
24
+ collapseInlineTagWhitespace: true,
25
+ collapseWhitespace: true,
26
+ conservativeCollapse: false,
27
+ continueOnParseError: false,
28
+ decodeEntities: true,
29
+ html5: true,
30
+ includeAutoGeneratedTags: true,
31
+ keepClosingSlash: false,
32
+ minifyCSS: { level: 2 },
33
+ minifyJS: true,
34
+ minifyURLs: false,
35
+ noNewlinesBeforeTagClose: false,
36
+ preserveLineBreaks: false,
37
+ preventAttributesEscaping: false,
38
+ processConditionalComments: false,
39
+ removeAttributeQuotes: false, // The HTML specification recommends to always use quotes, but technically they are optional in some cases.
40
+ removeComments: true,
41
+ removeEmptyAttributes: true,
42
+ removeEmptyElements: false,
43
+ removeOptionalTags: true,
44
+ removeRedundantAttributes: true,
45
+ removeScriptTypeAttributes: true,
46
+ removeStyleLinkTypeAttributes: true,
47
+ removeTagWhitespace: false,
48
+ sortAttributes: false,
49
+ sortClassName: false,
50
+ useShortDoctype: true,
51
+ }),
52
+ ],
53
+ });
54
+ ```
55
+
56
+ ## Installation
57
+
58
+ Add the integration to your Astro project using the `astro add` command.
59
+ This will install the adapter and make the appropriate changes to your
60
+ `astro.config.mjs`/`astro.config.ts` file in one step:
61
+ ```bash
62
+ npx astro add astro-html-minifier-next
63
+ ```
64
+ If you prefer to install the integration manually instead, complete the
65
+ following two steps:
66
+ 1. Install the integration to your project’s dependencies using your preferred
67
+ package manager.
68
+ If you’re using npm or aren’t sure, run this in the terminal:
69
+ ```bash
70
+ npm install --save-dev astro-html-minifier-next
71
+ ```
72
+ Or, if you're using Deno, run this in the terminal:
73
+ ```bash
74
+ deno add jsr:@jonasgeiler/astro-html-minifier-next
75
+ ```
76
+ 2. Add the integration to your `astro.config.mjs`/`astro.config.ts` file:
77
+ ```typescript
78
+ import { defineConfig } from "astro/config";
79
+
80
+ // ADD THE FOLLOWING LINE:
81
+ import htmlMinifier from "astro-html-minifier-next";
82
+
83
+ export default defineConfig({
84
+ // ...
85
+ integrations: [
86
+ // ...
87
+
88
+ // ADD THE FOLLOWING LINE:
89
+ htmlMinifier({ /* Your html-minifier-next options here. */ }),
90
+ ],
91
+ // ...
92
+ });
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ Once installed, the integration will automatically minify all HTML assets
98
+ generated by Astro during the build process using the provided
99
+ [html-minifier-next][html-minifier-next] options.
100
+
101
+ ### Options
102
+
103
+ You can find a quick reference of all available options in the
104
+ [html-minifier-next documentation][html-minifier-next-options].
105
+
106
+ > **Tip**
107
+ > I recommend setting `minifyCSS` to `{ level: 2 }`, and not `true` like
108
+ > most people do. This will apply more advanced optimizations to inline CSS,
109
+ > which can lead to smaller HTML files.
110
+ >
111
+ > More information can be found in the [clean-css documentation][clean-css].
112
+
113
+ ## Credits
114
+
115
+ This integration wouldn't be possible without the awesome work of
116
+ [Juriy Zaytsev (@kangax)][@kangax] ([html-minifier][html-minifier]),
117
+ [the Terser team][@terser] ([html-minifier-terser][html-minifier-terser]), and
118
+ of course [Jens Oliver Meiert (@j9t)][@j9t] ([html-minifier-next][html-minifier-next]).
119
+
120
+ [astro]: https://astro.build/
121
+ [html-minifier-next]: https://www.npmjs.com/package/html-minifier-next
122
+ [html-minifier-next-options]: https://www.npmjs.com/package/html-minifier-next#user-content-options-quick-reference
123
+ [latest-release]: https://github.com/jonasgeiler/astro-html-minifier-next/releases/latest
124
+ [package-on-bundlejs]: https://bundlejs.com/?q=astro-html-minifier-next
125
+ [package-on-jsr]: https://jsr.io/@jonasgeiler/astro-html-minifier-next
126
+ [package-on-npm]: https://www.npmjs.com/package/astro-html-minifier-next
127
+ [clean-css]: https://www.npmjs.com/package/clean-css
128
+ [@kangax]: https://github.com/kangax
129
+ [html-minifier]: https://github.com/kangax/html-minifier
130
+ [@terser]: https://github.com/terser
131
+ [html-minifier-terser]: https://github.com/terser/html-minifier-terser
132
+ [@j9t]: https://github.com/j9t
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "astro-html-minifier-next",
3
- "version": "0.2.1",
4
- "description": "Astro integration for html-minifier-next",
3
+ "version": "1.0.0",
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",
7
7
  "license": "MIT",
@@ -39,6 +39,21 @@
39
39
  },
40
40
  "./package.json": "./package.json"
41
41
  },
42
+ "keywords": [
43
+ "astro",
44
+ "astro-integration",
45
+ "html-minifier",
46
+ "html-minifier-next",
47
+ "html-minifier-terser",
48
+ "minifier",
49
+ "optimization",
50
+ "perf",
51
+ "performance",
52
+ "tooling",
53
+ "utility",
54
+ "utils",
55
+ "withastro"
56
+ ],
42
57
  "scripts": {
43
58
  "dev": "pnpm run build --watch",
44
59
  "check": "biome check",