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

Imported local aliases not working when used in selectors #561

Closed
apexskier opened this issue Jun 22, 2017 · 6 comments
Closed

Imported local aliases not working when used in selectors #561

apexskier opened this issue Jun 22, 2017 · 6 comments

Comments

@apexskier
Copy link

Reporting css-modules/icss#12 for visibility. I'll copy the details, but I'm experiencing the exact same issue.

Do you want to request a feature or report a bug?
bug report

What is the current behavior?

// foo.scss
.foo {
    color: blue;
}

// bar.css
:import("foo.css") {
    fooClassName: foo;
}
.fooClassName .bar { // <-- this doesn't get replaced :(
    color: red;
}

// baz.css
:import("foo.css") {
    fooClassName: foo;
}
.baz {
    color: fooClassName; // <-- this does get replaced :)
}

What is the expected behavior?
fooClassName is replaced with the local name for foo from foo.css in both bar.scss and `baz.scss

Please mention other relevant information such as your webpack version, Node.js version and Operating System.
I'm currently testing with webpack 2.2.1, node 7.2.1, css-loader 0.28.4.

@apexskier
Copy link
Author

It looks like this mght be fixed in a newer version of icss-utils css-modules/icss-utils@19ffee9

However, linking a local version of css-loader with icss-utils upgraded doesn't resolve the problem.

@apexskier
Copy link
Author

apexskier commented Jun 23, 2017

Okay, I'm diving in and have this PR, which partially solves this -- css-modules/postcss-icss-selectors#119 -- with a PR for this repo as well. It'll require updating to the more recent version of css-modules' icss loaders, but seems to be working well locally.

@michael-ciniawsky
Copy link
Member

Did you see the new-loader branch ? I highly appreciate your current work, but we need to be careful to not introduce breaking changes within the semver minor range of this loader atm. The intemediate goal is to release a new semver major of css-loader and move CSSM to postcss-loader as a standalone plugin, while css-loader only parses the ICSS Tokens. postcss-modules (Plugin Wrapper), postcss-loader (result.messages [ICSS Tokens Export]) and import @media query parsing (ICSS v2) are missing. In case your upcoming PR is backwards compatible forget what I said then 😛

@apexskier
Copy link
Author

Oh cool, that's very good to know. I was thinking about how it would be nice to use postcss for my modules, but the fact that the loader needs to know about the exports was blocking. That sounds like it'll help a lot with my issues.

I've got a draft of the PR and it might be backwards compatible (just need to investigate why some tests are failing). I'm going to push it up just so folks can look at it, but if it turns out to not be backwards compatible I won't worry.

@alexander-akait
Copy link
Member

Closing if favor css-loader/next and postcss-loader or css as first citizen in webpack. It is rfc/porpalse and should be resolve in https://github.com/css-modules/icss. Thanks for issue!

@apexskier
Copy link
Author

What's the status on this?

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

Successfully merging a pull request may close this issue.

3 participants