WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit dafb517

Browse files
authored
Merge pull request #30 from aminya/hydration-fix
2 parents 3dbdea3 + 9deab63 commit dafb517

File tree

4 files changed

+595
-404
lines changed

4 files changed

+595
-404
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
},
2525
"prettier": "prettier-config-atomic",
2626
"devDependencies": {
27-
"@types/node": "^20.11.24",
28-
"cspell": "^8.5.0",
27+
"@types/node": "^20.11.30",
28+
"cspell": "^8.6.0",
2929
"eslint": "^8.57.0",
30-
"eslint-config-atomic": "^1.20.6",
31-
"npm-check-updates": "^16.14.15",
30+
"eslint-config-atomic": "^1.21.2",
31+
"npm-check-updates": "^16.14.17",
3232
"npm-run-all2": "^6.1.2",
3333
"prettier": "3.2.5",
3434
"prettier-config-atomic": "^4.0.0",
3535
"readme-md-generator": "^1.0.0",
3636
"shx": "^0.3.4",
3737
"ts-readme": "^1.1.3",
38-
"typescript": "^5.3.3",
38+
"typescript": "^5.4.3",
3939
"typesync": "^0.12.1"
4040
},
4141
"engines": {

packages/astro-htmlnano/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
},
1616
"dependencies": {
1717
"astro-posthtml": "workspace:*",
18-
"cssnano": "^6.0.5",
18+
"cssnano": "^6.1.1",
1919
"htmlnano": "2.1.0",
20-
"postcss": "^8.4.35",
20+
"postcss": "^8.4.38",
2121
"relateurl": "^0.2.7",
2222
"srcset": "^5.0.1",
2323
"svgo": "^3.2.0",
24-
"terser": "^5.28.1"
24+
"terser": "^5.29.2"
2525
},
2626
"devDependencies": {
2727
"@types/relateurl": "^0.2.33"

packages/astro-htmlnano/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ import htmlnano, { type HtmlnanoOptions, type Presets } from "htmlnano/index.mjs
2020
*/
2121
export function getAstroHTMLNano(options?: HtmlnanoOptions, preset?: Presets[keyof Presets]) {
2222
if (process.env.NODE_ENV === "production") {
23-
return (_context: APIContext, next: MiddlewareNext) => getAstroPostHTML([htmlnano(options, preset)])(_context, next)
23+
return (_context: APIContext, next: MiddlewareNext) => {
24+
const htmlnanoOptions: HtmlnanoOptions = options ?? {}
25+
26+
// disable `removeComments` due to Astro's use of comments for hydration
27+
if (htmlnanoOptions.removeComments) {
28+
console.warn("`removeComments` is disabled due to Astro's use of comments for hydration.")
29+
}
30+
htmlnanoOptions.removeComments = false
31+
32+
return getAstroPostHTML([htmlnano(htmlnanoOptions, preset)])(_context, next)
33+
}
2434
}
2535
return (_context: APIContext, next: MiddlewareNext) => next()
2636
}

0 commit comments

Comments
 (0)