-
Notifications
You must be signed in to change notification settings - Fork 45
incompatibility with async plugins #58
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
Comments
@anru hi, I'm not sure that it's currently possible to support async plugins. The |
Well, there is not much problem, actually. In my case I just generate css modules map file at build time and use own hook that uses that map, so, may be a couple of words about it in Readme would be helpfull for someone else :) |
@anru yeah, looks like that question becomes more and more popular, so I'll add it to the readme. Can you tell me, what plugins you use with require hook and why? Usually you need to use require hook to generate tokens and exception may occur if you use non-css files. |
I'm using
And I get the async plugins error ... Hook setup looks like this, require('css-modules-require-hook')({
prepend: [require('postcss-import')(), require('postcss-cssnext')()]
}) The I've opened an issue at |
Can you expand on this a bit? Thanks :) |
Btw, I'm making some progress with https://github.com/istarkov/babel-plugin-webpack-loaders I think it removes the need for this require-hook by preprocessing your required modules synchronously with your Webpack loaders in a Node env ... |
@jedrichards Hi, thank you for your interest.
Yeah, I haven't checked, but it should help here. |
require.extensions['.css'] = function(m, filename) {
const map = require('css-modules.json');
const relativePath = path.relative(process.cwd(), filename);
const tokens = map[relativePath];
return m._compile(`module.exports = ${JSON.stringify(tokens)}`, filename);
}; Thats all |
@anru nice solution :) |
If you try to use require hook with any async plugin (for example
postcss-import
) you get errorthrow new Error('Use process(css).then(cb) to work with async plugins');
The text was updated successfully, but these errors were encountered: