postcss / postcss-cli

CLI for postcss
Other
836 stars 93 forks source link

How do I make 2 different configuration ?? #452

Closed alcapitan closed 1 year ago

alcapitan commented 1 year ago

I'm currently very frustrated by this error, especially as there's no explanation on the Internet and PostCSS doesn't indicate any error even in verbose mode.

Here is my NPM commands :

postcss atui/kernel/src/*.css --config .pre-postcssrc.json --replace --no-map
postcss atui/kernel/src/*.css -d atui/kernel/dist/ -m

This is my .pre-postcssrc.json config file :

{
    "plugins": {
        "cssnano": {
            "preset": ["default", { "normalizeWhitespace": false, "discardComments": false }]
        }
    }
}

And my .postcssrc.json config file :

{
    "plugins": {
        "cssnano": {
            "preset": ["default", { "discardComments" : { "removeAllButFirst": true } } ]
        },
        "postcss-import": {},
        "postcss-preset-env": {
            "stage": 2
        },
        "autoprefixer": {}
    }
}

I expect my first command with --config .pre-postcssrc.json to execute the .pre-postcssrc.json file, but it executes the .postcssrc.json file.

After a lot of testing, I think PostCSS ignores the --config option. However, the --config option appears in npx postcss --help as well as in the PostCSS-cli's README.

I'm using these versions :

Moreover, according to their package.json file, Bootstrap use the --config option, so it should works.

I want this way of operation. So please tell me how to fix that error.

RyanZim commented 1 year ago

The --config option specifies the directory to look for the config file, searching for the usual config file names. It cannot be used to specify a custom config file name. Bootstrap's usage is slightly incorrect; they should just use --config build/