Maiquu / nuxt-quasar

Quasar Module for Nuxt (Unofficial)
MIT License
161 stars 9 forks source link

[ENCH] Plugin adds unused quasar classes/css to generated html file #81

Closed OkanPinar closed 2 weeks ago

OkanPinar commented 11 months ago

Checks

Environment

Quasar version

2.14.1

Browsers

Firefox

Description

When adding Quasar to the Nuxt project via this extension and using it with ssr mode, the HTML file includes every style definition belonging to Quasar, therefore the size of documents is getting bigger enormously. It can be easily observed from the playground example. Is there any way to get rid of this situation?

Reproduction steps

1. Go to 'https://stackblitz.com/edit/github-g9bzsz?file=nuxt.config.ts'
2. Copy the generated HTML file
4. See the style section.

Screenshots

No response

Logs

No response

Maiquu commented 11 months ago

I will work on this when I have the time. However, since Quasar only provides the bundled CSS file, achieving this will be possible only when the user installs the sass package.

PabloFX commented 4 months ago

Hi @Maiquu any progress? is there any current workaround?

Maiquu commented 4 months ago

I don't think this is possible due to how quasar's runtime code is tightly integrated with its style definitions. Quasar concatenates strings with user provided props to build class strings. This will cause tools like PurgeCSS to make incorrect assumptions about what classes are unused. Even if you manage to make it work with PurgeCSS via safelist options, the gain will be minimal.

Only style definitions I can safely remove at module side are the ones belonging to unused components. This can maybe achieved by piggy-backing the rollup's tree-shaking process. But the gain from it may not be too great.