-
Notifications
You must be signed in to change notification settings - Fork 115
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
Resolve function behavior #216
Comments
This may seems like a bug. But to be honest v8 is pretty buggy. See #210. |
Ok so I dug around a bit and the default resolve function was no longer kicking in for files that did not match my regex. I have changed my code to: import postcssImport from 'postcss-import'
import postcssImportResolve from 'postcss-import/lib/resolve-id'
// ...
postcssImport({
addDependencyTo: webpack,
resolve: (id, base, options) => {
if (/^theme/.test(id)) {
return id.replace(/^theme/, PATH_THEME)
} else {
return postcssImportResolve(id, base, options)
}
}
}) and it seems to work now, although it is a rather ugly fix. I wonder if it's worth adding a check around where the resolve happens and apply the default |
Please consider this comment #169 (comment) |
I was able to resolve this issue by using the plugin |
Probably luck. Not sure it will work all the time on the long run... |
@cookpete I believe this is intended behavior. From the docs:
However, I agree that your use-case requires ugly workarounds.
Perhaps; I don't know if this is a good idea or not. I don't have time to work on/think about this ATM. If you make a PR, I will review it, though. |
@RyanZim what is the question? :) |
If someone passes a custom |
Why not? User show real useful case. In my opinion we should care about users if it is not dramatically reduce maintainability (and we have no reduce here). (Thanks for explanation) |
So you would be in favor of adding this? |
Yeap. Small nice sugar. |
This was changed in #249, see details there. |
Apologies for resurrecting this, but @cookpete, what was your PATH_THEME var equal to? I'm having a hard time getting this to work properly. |
This is a slightly tricky problem to explain so bear with me.
I am using
resolve
to enable some sort of "theme" system for my stylesheets. I am using a fairly simpleresolve
function:So now I can do:
and this will, for example, give me the variables from
src/themes/default/variables.css
for my default theme. Great.The problem happens when another imported file tries to import
variables.css
. For example, I add amixins.css
file with:and then I want to use
in my stylesheets, but it seems like the
resolve
rule is no longer kicking in for the deeper@import
. Now I get the error:You can see it's trying to open
theme/variables.css
which doesn't exist and isn't beingresolve
ed according to the configuration.Am I doing something wrong, or is this a bug/limitation of the
resolve
feature?The text was updated successfully, but these errors were encountered: