sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 343 forks source link

Plugins and Lifecycle #665

Open jdcauley opened 3 years ago

jdcauley commented 3 years ago

In issue #664 I mentioned how nice it could be to support plugins via possibly lifecycle hooks.

I'm opening this issue to continue the discussion.

Use Cases

11ty provides a plugin model that could be evaluated for its merits, the biggest frustration I had with 11ty is that it was very extendable but the initial start up curve was steeper than I expected.

Being able to start with something simple and light weight as starting a harp project but being able to also implement plugin capabilities would make it hard to be in my opinion.

jdcauley commented 3 years ago

With the right lifecycle hooks issues like #517 could be more rapidly addressed and evaluated.

Additionally, in the above case having lifecycle hooks could let folks start with sensible defaults and replace some operations if they would prefer operations to preform differently than the default

sintaxi commented 3 years ago

@jdcauley Thanks for starting this discussion. I definitely think there are things we can do.

I like your idea of starting with the use cases...

  1. ESbuild will give us lots of this for free we just need to expose some easy to use flags with sane defaults
  2. PostCSS seems like the way to go. I recently removed it from terraform but it should be added back in a way that makes it easy to extend if one wants to. Finding a golden path with tailwind I think is important here.
  3. A plugin system for crating template functions makes sense so it can be called the same way we call partial()
  4. We can expose a way to processing the output of any file type. Is String or Buffer the way to go here? Not sure.

Thats all I got for now. The most important thing to me is harp remains small and is good enough without the use of any plugins or extensions.

It might be helpful to make a list of all the most popular plugins from other systems (by number of downloads). Is that something you want to take on?

jdcauley commented 3 years ago

Example integrations/customizations file for an 11ty build: https://github.com/jdcauley/eleventy-starter-ghost/blob/master/.eleventy.js

I know this might sound insane, but I genuinely think that WordPress' hooks system would not be a bad way to think about these types of manipulations.