Closed natemoo-re closed 1 year ago
The compiler already has a flag that minifies markup from Astro components at compile time, which as far as I'm aware is unused in the framework.
I had a different discussion that briefly outlines how to get this method working, it's a couple of lines of code: https://github.com/withastro/roadmap/discussions/511. Not sure how much it applies given the "long answer."
Do we need to support it as a new flag?
Such as pnpm run build --compact
.
And by default is true?
@matthewp cc
@paperdave, the bundle was partially compressed. Please check again.
I think we want a config option, yes. Probably build.compressHTML: true
?
I think we want a config option, yes. Probably
build.compressHTML: true
?
Ok, no problem. I will continue when that bug of the compiler has been fixed.
@natemoo-re Where should the option for this go? I previously suggested build.compressHTML
but how I realize this is both dev and build. Should this be top-level compressHTML
?
@matthewp Should the html actually be compressed when developing?
@natemoo-re Where should the option for this go? I previously suggested
build.compressHTML
but how I realize this is both dev and build. Should this be top-levelcompressHTML
?
I propose it only supports pro. so supporting build.compressHTML
.
because the users don't need to see HTML that was compressed in most of the scenes in the dev.
In general, having it behave differently in dev vs production can trip developers up — if minification is the source of a bug, you don't see it until you get to a production or staging environment. So I'd suggest consistent dev & prod behaviour (which a user can then change by using a ternary in the config or passing a flag).
In general, having it behave differently in dev vs production can trip developers up — if minification is the source of a bug, you don't see it until you get to a production or staging environment. So I'd suggest consistent dev & prod behaviour (which a user can then change by using a ternary in the config or passing a flag).
OK, I agree. I will follow what you said while I develop.
This was released in 2.5.
Body
Summary
When building for production, we should safely collapse whitespace when generating the HTML
Background & Motivation
Astro users are often confused why we don't minify HTML by default.
The long answer is:
server
modeThe shorter answer is:
Goals
Non-Goals
Example
Probably just a boolean config option. Name TBD.