posthtml / posthtml-cli

CLI for PostHTML
MIT License
29 stars 18 forks source link

[fix]: Using posthtml-cli with postcss autoprefixer #246

Open mickeywu opened 7 years ago

mickeywu commented 7 years ago

I'm having problems using the CLI with PostCSS Autoprefixer. I already have posthtml-postcss and autoprefixer packages installed through NPM.

posthtml.json

{
  "posthtml": {
    "postcss": {},
    "plugins": {
      "autoprefixer": {
        "browsers": ["last 2 versions"]
      }
    }
  }
}

Running posthtml -i src/**/*.html -o posthtml/ -c posthtml.json gives me the following error:

(node:17883) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 79): Error: [object Object] is not a PostCSS plugin

After digging into the posthtml-postcss documentation (https://github.com/posthtml/posthtml-postcss), postcss expects a postcssPlugins argument (which is an array) before the usual options argument, as such:

posthtml([ postcss(postcssPlugins, postcssOptions, filterType) ])
    .process(html)
    .then((result) => console.log(result.html))

What is the proper way (if any) to pass in a list of plugins specifically for PostCSS through the CLI?

Scrum commented 7 years ago

@mickeywu Hi, thanks for feedback, Is associated with incorrect work post-load-plugins. I'm working on it.

Scrum commented 6 years ago

@mickeywu Hi, I fixed a rejection

(node:17883) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 79): Error: [object Object] is not a PostCSS plugin

but not resolves case with plugin posthtml-postcss(( I create issue what would fix it.