posthtml/posthtml-include

How can I use it with parcel

cocodrino opened this issue · 2 comments

Hello, It's not totally clear for me how use posthtml with parcel, basically my case is similar to the example provided in the readme file, I've an index.html and I want to include some component inside it (similar to button.html in the example)

the parcel documentation says that I can create a configuration file, in my case I use the name .posthtmlrc

https://parceljs.org/transforms.html#posthtml

but it's not clear what I need put inside this file...I try this

  "plugins": {
    "posthtml-include": {}
  }
}

and this

  "plugins": {
    "include": {}
  }
}

and this

{
  "plugins": {
    "include": {
      "encoding": "utf8"
    }
  }
}

but they didn't work...I'd appreciate if you can give me a help with this...thank you so much!!!

I also try this option

but doesn't works, it's not including the html

I create this test repo

https://github.com/cocodrino/error-posthtml

ok..after read the comment parcel-bundler/parcel#395 (comment)

I include the html files inside a src folder and put this config

{
  "plugins": {
    "posthtml-include": {
      "root": "src"
    }
  }
}

this works, the problem right now is that in my real project I can't move my html files inside a new folder, so I'd need that this plugin works in the root folder, I try as root "" , "/", "." without luck

also I think would be great if you can add this info in the readme, other people would find useful, thank you