Skip to content
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

feat: add ID's to <style> tags #336

Closed
wants to merge 6 commits into from
Closed

Conversation

alex-mm
Copy link

@alex-mm alex-mm commented Jul 25, 2018

fix: #216

@jsf-clabot
Copy link

jsf-clabot commented Jul 25, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@codecov
Copy link

codecov bot commented Jul 25, 2018

Codecov Report

Merging #336 into master will increase coverage by 0.45%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #336      +/-   ##
==========================================
+ Coverage   98.43%   98.88%   +0.45%     
==========================================
  Files           4        5       +1     
  Lines          64       90      +26     
  Branches       21       26       +5     
==========================================
+ Hits           63       89      +26     
  Misses          1        1
Impacted Files Coverage Δ
index.js 100% <100%> (ø) ⬆️
lib/utils.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc24512...0b31101. Read the comment docs.

options.attrs[key] = options.attrs[key]
.replace(/\[name\]/ig, pkg.name)
.replace(/\[version\]/ig, pkg.version);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need use loader-utils.interpolateName (https://github.com/webpack/loader-utils#interpolatename).
Also find-package doesn't works good with mono repos, please don't use this package.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. find-package has been removed.
  2. But loader-utils.interpolateName is unsatisfactory. We need to get the version number of the package corresponding to the current file.
  3. is there a better way to get it than from package.json?

@alexander-akait
Copy link
Member

Why you need version here? Better add this attribute using own configuration, it is not universal solution

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #317 for a possible solution to add the url (as id) (data-id/data-url) in a more generic way to the <style> tags. Using your current approach searching for the package and using the package name as an id instead isn't a generic solution and it should also be avoided to use fs from within a loader. webpack already gives us the request (url) and we can manipulate it to get an acceptable identifier

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Aug 28, 2018

Closing due to inactivity feel free to reopen once the requested chances are addressed :)

@m-orsh
Copy link

m-orsh commented Jan 9, 2020

Lets say I have 2 standalone apps. Each one needs to check whether the css libraries it needs have been loaded prior to loading them. If I load app 1, and this loads some css libs that app 2 also will use, without a method of identifying the css I have imported, how can I identify if the css has already been loaded? I think the only good way is with this feature.

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

Successfully merging this pull request may close these issues.

Add ID's to <style> tags
5 participants