Closed mikemcguire closed 7 years ago
It appears that the colorfunction is somehow finding a way to execute before my other postcss plugins after initially executing in the correct order. Any ideas?
This is not possible. Is the code of the mixin itself removed? Maybe color-function tries to transform the mixin definition.
I don't believe that would be the case as it's hanging up on the "$purple" keyword which doesn't appear in the mixin definition itself. Let me get a repo together isolating the issue and I'll send that over that way we can replicate and test against.
Isolated bug appreciated. Feel free to push a PR with a failing test!
I see this as well. This example doesn't work:
@value colors: "colors.css";
@value primary from colors;
.root {
color: color(primary, l(30%));
}
I get this error: Unable to parse color from string "primary,"
@luisrudge this is different. You are using css modules syntax, which is converted AFTER postcss-loader stuff. So when postcss-loader does its job, css modules have not made their transformation. css-loader should offer a way to share the postcss instance, that would offer us a way to handle those issue, but they don't want to make postcss public so they can do "whatever they want under the hood".
so, what's the alternative here?
use "standard" stuff like potcss-custom-properties, or non standard like postcss-simple-vars
Sorry for the delay on this test case. I'm in crunch mode with some projects at work. I'll hopefully have something in the next week or so.
hei there,
i'm also having an issue while using postcss-style-guide
.
Unable to parse color from string "var(--color-bg)"
this is the postcss config
postcss([
require('postcss-import'),
require('postcss-custom-properties')({preserve: true}),
require('autoprefixer')({ browsers: ['last 3 versions', '> 5%', 'ie >= 10'] }),
require('postcss-color-function'),
styleGuide({
project: 'My Project',
dest: 'styleguide/app.html',
showCode: true
}),
require('postcss-atroot'),
require('postcss-mixins'),
require('postcss-simple-vars'),
require('postcss-custom-media'),
require('postcss-nested'),
require('postcss-typescale'),
require('postcss-button'),
require('cssnano')({
discardComments: {
removeAll: false
}
})
])
.process(fs.readFileSync('resources/games/css/app.css', 'utf8'), { from: "resources/games/css/app.css" })
.then(result => purify(content, result.css, options))
process.on('exit', () => console.timeEnd('build'))
The problem is here: "preserve: true" of custom-properties.
can't figure the problem; if i remove that, there's no output
Sorry for the lack of isolated bug. Got way busy with work after my original comments. Hopefully coming soon?
Problem should have been fixed with latest change in master.
Reopen if not.
I'm not quite sure what the problem I am having is, but let me explain my setup and you might be able to provide some insight into why Im experiencing this strange behavior.
I'm using the mixins plugin and the variables plugin. I have colorFunction() at the bottom of my postcss processors.
One of my color variables:
My mixin
Calling the mixin
When I run my gulp task I get this error
Why this is weird - I'm runnning my color function at the end of my postcss processors so it shouldn't even see the string "$purple"
Even though my gulp task errors out the mixin runs as expected. I can see the correct active state on my button with the correct color manipulation.
If I keep everything as is but remove
colorFunction()
from my gulp task I can see this as my active state background property:It appears that the colorfunction is somehow finding a way to execute before my other postcss plugins after initially executing in the correct order. Any ideas? Let me know if I can provide more info