postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
597 stars 77 forks source link

Doesn't sequence with nano #156

Open MichaelRFox opened 5 years ago

MichaelRFox commented 5 years ago

I am running nano and postcss-custom-properties, and on about every fourth or fifth build instead of replacing the custom properties in the target .css file, the entire .css file is replaced by the custom properties in my customProperties.json file.

I suspect that postcss-custom-properties is starting to execute before nano copies the .css files from my ./src directory, so finding no target .css file, merely creates a target .css file with a copy of the custom properties in my customProperties.json file.

The script from my package.json:

    "postcssTest": "postcss src/**/*.css -d test --config ./test",

My .postcssrc:

{
    "use": ["autoprefixer", "cssnano", "postcss-custom-properties"],
    "plugins": {
        "autoprefixer": {},
        "cssnano": {
            "preset": [
                "default",
                {"normalizeWhitespace": false}
            ]
        },  
        "postcss-custom-properties": {
            "preserve": false,
            "importFrom": "./src/customProperties.json",
            "exportTo": [
                "./test/breadcrumb.css",
                "./test/fyControl.css"
            ]
            }
    }
}
jonathantneal commented 5 years ago

I’m not sure what the issue is here, as postcss-custom-properties does not resolve asynchronously until all of the exports have been written.

Is there a chance this function is being executed again before it is complete? I’m unsure, myself.