HenrikJoreteg / moonboots

A set of conventions and tools for bundle and serving clientside apps with node.js
158 stars 20 forks source link

feature request: allow beforeBuild functions to pass code directly to bundle #49

Closed lukekarrys closed 9 years ago

lukekarrys commented 10 years ago

Using the browserify require method, you can pass in a stream and an expose parameter to add a module to the bundle.

So, for example templatizer could pass its content directly to browserify instead of writing to a file and then reading from that file. Especially in cases where you don't check in any generated files, I think this can be cleaner.

The API could look like this and then under the hood it could convert the string to stream and expose it as templates.

beforeBuildJS: function (cb) {
  cb(null, {
    templates: {
      content: templatizer('./client-templates'),
      // Other browserify require options
    }
  });
}

This could be extended to beforeBuildCSS by just appending/prepending to the CSS.

lukekarrys commented 9 years ago

I tried this at one point but it was blocked by a browserify bug, but I now forget which one. Either way, I'm gonna close this at it seems too complex now and likely won't happen.