Skip to content

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

Description

@mickeywu

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?

Activity

  1. self-assigned this
    on May 23, 2017
  2. Scrum commented on May 23, 2017

    @Scrum
    Member

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

  3. modified the milestones: , 0.3.0, 0.3.1 on May 26, 2017
  4. changed the title [-]Using posthtml-cli with postcss autoprefixer[/-] [+][fix]: Using posthtml-cli with postcss autoprefixer[/+] on Jun 28, 2017
  5. modified the milestones: 0.3.1, 0.3.2 on Oct 10, 2017
  6. modified the milestones: 0.3.2, 0.3.3 on Jan 19, 2018
  7. Scrum commented on Jan 22, 2018

    @Scrum
    Member

    @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.

  8. removed this from the 0.3.3 milestone on Feb 14, 2018
  9. 10 remaining items

  10. modified the milestones: 0.4.5, 0.4.6 on Mar 2, 2018
  11. modified the milestones: 0.4.6, on Mar 16, 2018
  12. modified the milestones: , 0.4.8 on Sep 4, 2018
  13. modified the milestones: 0.4.8, 0.4.9 on Oct 11, 2018
  14. modified the milestones: 0.4.9, 0.4.10 on Apr 1, 2019
  15. modified the milestones: 0.4.10, 0.4.11, hold on Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions