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

preprocessCss is no longer run on composed files #115

Open
willdawsonme opened this issue Apr 4, 2018 · 2 comments
Open

preprocessCss is no longer run on composed files #115

willdawsonme opened this issue Apr 4, 2018 · 2 comments

Comments

@willdawsonme
Copy link

Since css-modules-require-hook started using postcss-modules-resolve-imports (v4.2.2), preprocessCss is no longer being called on composed files, which makes using this module with stylus impossible if you use composes.

For example, this:

// src/components/Home/styles.styl
.header
    composes: header from '../styles/page.styl'

should give me:

// src/components/Home/index.js
styles = {
    header: 'styles__header__abcd page__header__abcd',
}

but instead I get:

// src/components/Home/index.js
styles = {
    header: 'styles__header__abcd header',
}

because page.styl isn't being preprocessed before postcss is run.

@XOP
Copy link

XOP commented May 31, 2018

Finally! that's the crux of the matter I've been struggling with for 2 days... Thanks @willdawsonme!

My setup runs exclusively on .scss modules, but the reason it fails is the same - no call on composed files, as mentioned above.
Had to resort to 4.2.1 to make it work.

Perhaps it wouldn't be the case if it was different setup. In my case it's modules nesting that produce such results.

P.S. I use require hook only for testing purposes.

birdofpreyru added a commit to birdofpreyru/css-modules-require-hook that referenced this issue Apr 17, 2020
This issue:
css-modules#115

The version v4.2.2 introduced a breaking change for people relying on
`processCss` option. The actual reason was that since that version
"postcss-modules-resolve-imports" combined separate CSS into single CSS
prior to triggering processCss callback, if any was provided. Up to
4.2.1 the behavior was different, and processCss was called on each
individual file.

This patch, if `processCss` callback is provided, with a help of
additional simple plugin, records separate compiled CSS files, and then
passes them to `processCss` callback individually, with the same order
as before.

As of now, I am not sure it solves the issue in all corner cases, but at
least with this patch `babel-plugin-css-modules-transform` passes all
its functional tests when upgraded to the v4.3.1 of
`css-modules-require-hook`.
@birdofpreyru
Copy link

birdofpreyru commented Apr 17, 2020

If anybody is still interested, I presumably fixed this in my fork of the library, published to NPM: https://www.npmjs.com/package/@dr.pogodin/css-modules-require-hook

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