css-modules / postcss-icss-values

Pass arbitrary constants between your module files
MIT License
203 stars 18 forks source link

Usage with postcss-import and postcss-mixins #108

Open penx opened 6 years ago

penx commented 6 years ago

See this example project:

https://github.com/penx/postcss-import-values-mixins

I have a css file (src/main.css) that imports another CSS file with a mixin:

@import "./mixins/fonts";

The mixin css file loads a variable:

@value title_font from '../variables/fonts.css';

But when running npm run webpack, I receive the error:

    ERROR in ./node_modules/css-loader?{"importLoaders":1}!./node_modules/postcss-loader/lib!./src/main.css
    Module not found: Error: Can't resolve '../variables/fonts.css' in '/postcss-import-values-mixins/src'

If I change the path to the variables css file to this:

@value title_font from './variables/fonts.css';

(using . rather than ..)

...then it works. But this is not the correct path relative to the file it is in.

This seems to indicate that postcss is trying to process the path to the src/variables/fonts.css file relative to src/main.css, rather than relative to src/mixins/fonts.css.

Is this a bug, or is there an issue with my configuration?