lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
582 stars 75 forks source link

Add init function in writer plugins #247

Closed austinkelleher closed 7 years ago

austinkelleher commented 7 years ago

Writers should be able to expose an init function that gets called only once before writeBundle or writeResource gets called.

module.exports = function(lasso, config) {
    lasso.config.writer = {
        async init (lassoContext) {
          // This will get called once before either `writeBundle` or `writeResource`
        },

        async writeBundle (reader, lassoContext) {
          ...
        },

        async writeResource (reader, lassoContext) {
          ...
        }
    };
};