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

Reusing css file puts duplicate styles in <head> #99

Open
timwis opened this issue Oct 7, 2016 · 3 comments
Open

Reusing css file puts duplicate styles in <head> #99

timwis opened this issue Oct 7, 2016 · 3 comments

Comments

@timwis
Copy link
Contributor

timwis commented Oct 7, 2016

I have a few components that are similar and I'd like to share styles between rather than copying & pasting the styles into each component. So I put the shared styles into a .css file and imported them into each component via sf('path/to/styles.css'). Fortunately sheetify seems to know it's the same file so it uses the same class name for both components. But it still puts the contents of the .css file into the <head><style> tag twice:

screen shot 2016-10-07 at 06 53 57

Is that expected behaviour? Is there a better way to accomplish what I'm trying to do? The only other thing I can think of is to put the css on the parent element, but that feels like unnecessary coupling. Or use insert-css to just add css like olden times.

@yoshuawuyts
Copy link
Contributor

I think this would be an optimization; when using extract-css it might make sense to dedupe classes for stuff like this. Does that make sense?

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Oct 20, 2017

maybe we can do something like this in the output:

require('sheetify/insert')('css text', 'hash of css text')

and not insert duplicate hashes (could the prefix be used that way?). that would be for dev, everything would still be duplicated in js so it doesn't save on size there. css-extract could check the hash and discard anything it has already extracted for prod.

@yoshuawuyts
Copy link
Contributor

yoshuawuyts commented Oct 20, 2017 via email

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

3 participants