webpack-contrib / mini-css-extract-plugin

Lightweight CSS extraction plugin
MIT License
4.65k stars 389 forks source link

Can support specify the position when insert CSS asynchronously? #504

Closed kingller closed 4 years ago

kingller commented 4 years ago

Feature Proposal

When insert CSS asynchronously, insert it before a style link, because the position of the css file will affect its weight.

mainTemplate.hooks.requireEnsure.tap(
   ...
   'var head = document.getElementsByTagName("head")[0];',
   'head.appendChild(linkTag);',
   ...
)

Can I pass in a string to replace the words bellow?

'head.appendChild(linkTag);'

Feature Use Case

I extracted a theme color file to switch theme colors. Then I want to insert CSS asynchronously before it (when dynamic import used) to keep the styles of theme color file override the inserted file.

kingller commented 4 years ago

Now I use css-async-process-webpack-plugin to solve this issue.

alexander-akait commented 4 years ago

It was solved in the near future, https://github.com/webpack-contrib/mini-css-extract-plugin/pull/495

kingller commented 4 years ago

OK. Thanks very much.