Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kingller opened this issue Feb 25, 2020 · 3 comments
Closed

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

kingller opened this issue Feb 25, 2020 · 3 comments

Comments

@kingller
Copy link

kingller commented Feb 25, 2020

  • Operating System:
  • Node Version: 12.13.1
  • NPM Version: 6.12.1
  • webpack Version: 4.41.2
  • mini-css-extract-plugin Version: 0.8.0

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
Copy link
Author

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

@alexander-akait
Copy link
Member

It was solved in the near future, #495

@kingller
Copy link
Author

OK. Thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants