Closed jlengstorf closed 6 years ago
I think it comes from the use of postcss-cssnext
, which uses postcss-custom-properties
. I ran into it just from importing a css file into src
. This issue may be relevant.
Yep this is from cssnext which Gatsby bundles. That's going away in v2, but the easiest fix for now is just to nuke Gatsby's postcss config and provide your own (eg: just autoprefixer).
See: https://github.com/gatsbyjs/gatsby/issues/3284#issuecomment-386861512
Closing since v2 solves this.
Description
In V1 using CSS modules, the CSS custom properties get compiled away. I'm inclined to blame this on an optimization step (cssnext/cssnano?), or maybe Autoprefixer, but I haven't had the chance to look into it.
Steps to reproduce
1. Create a file with CSS custom properties
Example: https://github.com/jlengstorf/lengstorf.com/blob/master/src/styles/_variables.css
2. Import it into a CSS module
Example: https://github.com/jlengstorf/lengstorf.com/blob/7fd8d4efed4e8731e25b01b3cab24011643bb3e0/src/styles/blog.module.css#L1
3. The compiled output replaces custom properties with hard-coded values
Source: https://github.com/jlengstorf/lengstorf.com/blob/7fd8d4efed4e8731e25b01b3cab24011643bb3e0/src/styles/blog.module.css#L52-L53
Output:
Expected result
The source should output custom CSS properties with a fallback, per https://github.com/postcss/postcss-custom-properties#notes
Actual result
Only the hard-coded values were included.
Environment
npm list gatsby
): gatsby@1.9.223gatsby --version
): 1.1.49File contents (if changed):
gatsby-config.js
:package.json
: