nystudio107 / rollup-plugin-critical

Vite.js & Rollup plugin for generating critical CSS
MIT License
91 stars 11 forks source link

Ability to use an array for criticalUrl #3

Closed TomDeSmet closed 2 years ago

TomDeSmet commented 2 years ago

Would it be possible to have the criticalUrl property accept an array of URL's that calls critical.generate() multiple times and have the resulting files prefixed with the second level domain of the URL? This way we can use it together with multi-site in Craft for example.

khalwat commented 2 years ago

This plugin shouldn't get involved in terms of knowing anything about "multi-site" or the like, that's too specific to Craft.

TomDeSmet commented 2 years ago

I wasn't referring to the plugin knowing anything about Craft, just the possibility of adding an array of urls to the Vite config. And if it is an array, files should be prefixed so they can have unique filenames.

This has nothing to do with Craft, but it does allow us to use it together with Craft by adding the urls manually in the Vite config. I get the feeling you closed my request without reading it...

edited title and first post to make myself more clear.

development-lameco commented 2 years ago

I'm wondering how one would go about setting this plugin up with a multi-site Craft CMS.

Because in the config you set a criticalUrl and criticalPages with an URI to an existing URL belonging to an entry in the Craft CMS with a changeable slug. What if the slug of the entry changes, you would have to change to URI in the criticalPages to match the new URL. Else how would {{ craft.vite.includeCriticalCssTags() }} know to output the previously generated Critical CSS?

khalwat commented 2 years ago

If you have special needs, I'd suggest writing a script that calls critical directly; probably this Vite plugin isn't going to do what you need.