Replies: 2 comments 5 replies
-
Hi, thanks for comment. Sorry if I didn't express myself well, I was thinking if this is possible with In the new Next.js docs, minification is mentioned as one of the new big features, and also migration from terser. Nothing about this topic was mentioned in the official |
Beta Was this translation helpful? Give feedback.
-
@alexander-akait Hi, thanks for all the info and examples, it definitely helped. Here's an example with which I was partially able to set up the minification, but it seems to automatically remove the The rest of the content is minified and works fine in the browser, but is not correct without the removed tags. Although I think I have set something wrong, here is my example, maybe you have some advice: // vite-plugin for SvelteKit
import swcHtml from '@swc/html'
{
return {
name: 'vite-plugin',
async closeBundle() {
// htmlFiles -> array of all .html files in dir
for (let file of htmlFiles) {
// open file and get full html content with doctype and everything else
let fileContent = readFileSync(file, 'utf-8')
// minify html content
// not sure about that Buffer.from(), is that set correctly?
let minifiedContent = await swcHtml.minify(Buffer.from(fileContent))
// write minified content back to the file
writeFileSync(file, minifiedContent.code)
}
}
}
} Also, can't believe that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I just found out about this project through Vercel's new blog post. I had a quick look through the documentation so I hope this question isn't ridiculous :D
Is it possible to minify the
html
content? Maybe something like this, but forhtml
:Beta Was this translation helpful? Give feedback.
All reactions