question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unclear for workbox-recipes, htmlMinifier with create-wmr

See original GitHub issue

For workbox-recipes, you said in the doc https://github.com/preactjs/wmr/tree/main/packages/sw-plugin#usage

So, do we need yarn add workbox-recipes? In your demo, it seems like we need to install it. Maybe add a sentence to make it clear.


After using create-wmr, we have defineConfigand in package.json we have rollup-plugin-html-minifier. And in https://github.com/preactjs/wmr/wiki/Configuration-Recipes#minifying-html, we should add plugins: [htmlMinifier()] to defineConfig, but we didn’t see plugins: [htmlMinifier()] in default defineConfig.

It’s unnecessary to add it?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rschristiancommented, Apr 11, 2022

I should say that adding rollup-plugin-html-minifier to your plugins by itself will do nothing; we already minify according to its defaults. You can customize the options of that plugin to minify further, but those are things it has not enabled by default for various reasons.

Now, what content can be minified is a bit limited as prerendering happens after the build, so you can’t actually use that plugin to minify most of your HTML further, unfortunately. If you set removeAttributeQuotes, for example, you’ll only see that effect the content already in your index.html. It won’t minify anything that’s created from the prerender.

1reaction
rschristiancommented, Apr 11, 2022

So, do we need yarn add workbox-recipes?

Yes, you will. You’re right, probably worth adding.

preact/compat in your defineConfig -> alias, but I remember we have package “preact-compat”.

preact-compat is legacy compat, only for use in Preact v8 and older. In v10, compat moved into the main package. hence preact/compat. 1 less install for users.

https://preactjs.com/guide/v10/upgrade-guide#compat-has-moved-to-core

but we didn’t see plugins: [htmlMinifier()] in default defineConfig.

The defineConfig that comes in the template is empty, but you can add additional keys. See https://wmr.dev/docs/configuration

Read more comments on GitHub >

github_iconTop Results From Across the Web

GitHub - minify HTML, CSS and JS code using terser - GitHub
HTMLMinifier is a highly configurable, well-tested, JavaScript-based HTML minifier. Installation. From NPM for use as a command line app: npm install html- ...
Read more >
html-minifier - npm
Highly configurable, well-tested, JavaScript-based HTML minifier.. Latest version: 4.0.0, last published: 4 years ago.
Read more >
Html minifier in client side [closed] - javascript - Stack Overflow
My project is a webapp who generate html template dynamically with form value. – ZecKa. Dec 17, 2020 at 15:22. You could modify ......
Read more >
Top 5 html-minifier Code Examples - Snyk
Learn more about how to use html-minifier, based on html-minifier code examples created from the most popular ways it is used in public...
Read more >
Experimenting with HTML minifier - Perfection Kills
In Optimizing HTML, I mentioned that state of HTML minifiers is rather ... Javascript-based HTML minifier and created an online-based tool, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found