Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Up a config file for PostCSS

Tags:

html

css

postcss

I'm using PostCSS and I want to add Post-uncss. I use no task runners, just Postcss-cli. My package.json looks like this right now:

"css-clean": "npx postcss src\\css\\main.css -u autoprefixer --replace && npx postcss src\\css\\main.css -u css-declaration-sorter --replace --no-map"

It's getting rather long. I saw mentioned that PostCSS can have a config file "postcss.config.js". The only thing mentioned in the article is the skeleton:

module.exports = {
    plugins: {
      'autoprefixer': {},
      'css-declaration-sorter': {}
    }
  };

The uncss documentation just says for options:

{
  html: ['index.html', 'about.html', 'team/*.html'],
  ignore: ['.fade']
}

I was hoping if someone has experience with using the config file to give some advice because I don't believe this feature is well documented.

like image 793
Alan Avatar asked Sep 04 '25 03:09

Alan


1 Answers

You can pass plugin parameters within a postcss.config.js file like so:

module.exports = {
    plugins: [
        require('module-name-1'),
        require('module-name-2')({
            option-a: 1,
            option-b: "quoted value",
        }),
    ],
 };
like image 122
Hynes Avatar answered Sep 06 '25 14:09

Hynes