egoist / rollup-plugin-postcss

Seamless integration between Rollup and PostCSS.
MIT License
672 stars 212 forks source link

[feature] linkTag injection type #319

Open benmccann opened 3 years ago

benmccann commented 3 years ago

Webpack's style-loader has several different injectTypes. It would be nice if some of these options were supported here as well. My motivation for asking is that I'm wondering if the number of style tags created by the plugin today would result in optimal performance. It seems like we could recalculate the CSSOM fewer times by injecting only a single style tag per chunk. And injecting the styles via a link tag might result in reduced data transfer for hydrated apps, which would be quite nice

I think that the extract option in this plugin creates only a single CSS file? It would be nice if there were a way to create one css chunk per js chunk in order to support this feature. Then I might be able to provide a function to inject in order to write the link tag myself.

benmccann commented 3 years ago

I've got a version of this working here: https://github.com/sveltejs/sapper/blob/a05ba1b7dd13b0216165bc5e9767bf6e6870e153/src/core/create_compilers/RollupCompiler.ts#L129

Feel free to steal it!

o-mega commented 3 years ago

+1 to add this feature