cabbagejs / cabbage

A CLI for building conventional web applications with Broccoli
MIT License
5 stars 0 forks source link

Support plugins #38

Open TravisTheTechie opened 9 years ago

TravisTheTechie commented 9 years ago

Support Cabbage plugins, like Lineman does. Maybe anything that's cabbage- in the node_modules?

searls commented 9 years ago

Yeah, this is something that I'm pushing off for now because we don't know what that should look like.

Thoughts so far:

  1. The magicness of Lineman's plugins is great, but it's mostly just global config stomping, which makes the interplay of plugins really dicey. A more formal option would be best
  2. I like the idea of just extracting broccoli plugins for our purposes but simply having a "cabbage: true" option for pre-configuring themselves for the conventional lineman layout
  3. The reason (2) might work is because if you look at Cabbage's brocfile, a plugin could just as well wrap cabbage() and provide a modified tree. This won't be a panacea, but at least an API exists now, which wasn't really true of Grunt
  4. I want to look into how ember-addons work in ember-cli. Ideally we could just build support for those and get at the awesome ecosystem of ember-addons without reinventing the wheel
TravisTheTechie commented 9 years ago

What if we had just a couple places in the config where you could inject something via the config into the tree?

pipeline:
  js:
    jsAddon:
       configFor: "this-addon"
       output: "<%= files.js.generated %>"
    tree: [
      (config) -> require('broccli-js-addon')(config.pipeline.jsAddon),
      etc
    ]

And we just merge those into the tree?

searls commented 9 years ago

I'm not understanding your suggestion quite

TravisTheTechie commented 9 years ago

Then change js.coffee to be something like...

  uglify(merge(
    _.map(config.pipeline.js.tree, (item) -> item(config))
    concatenated,
    exportTree(concatenated, destDir: 'generated') if env != "production"
  ))

But not exactly because I assume that merge won't accept an array at the moment. Do the same for CSS, can support stylus, less, etc. Do it for pages and can support markdown/etc.

TravisTheTechie commented 9 years ago

Not suggesting this is a great idea. Just brainstorming lower impact ways to extend.

searls commented 9 years ago

This doesn't feel right to me yet. I want to keep stewing for a bit