dowjones/gulp-bundle-assets

Add Gulp-Remember Into Bundle Flow

Opened this issue · 3 comments

Adding the ability to configure/enable gulp-remember will help make large bundles faster during development.

Adding gulp-remember is already possible to the main bundle task, e.g.:

gulp.task('lessMain', function() {  
    return gulp.src(projectPaths.cssMainConfig)        
        .pipe(cache('less'))
        .pipe(remember('less'))
        .pipe(bundle())        
        .pipe(bundle.results({
            fileName: 'main.result',
            dest: projectPaths.cssResults,
            pathPrefix: '<%=request.getContextPath()%>/dist/styles/'
        }))        
        .pipe(gulp.dest(projectPaths.cssDist));
});

However, an enhancement needs to be added to gbundle.watch to allow actions to run on change. I'm thinking of a config option like so:

gbundle.watch({
    configPath: path.join(__dirname, 'bundle.config.js'),
    results: {
      dest: __dirname,
      pathPrefix: '/public/',
      fileName: 'manifest'
    },
    dest: path.join(__dirname, 'public'),
    onChange: function (event) { // custom on change event handler
        if (event.type === 'deleted') {
            delete cache.caches['scripts'][event.path];
            remember.forget('scripts', event.path);
        }
    }
});

How does that sound?

@chmontgomery I like that, simple enough!

That looks like a great addition to the API. Some of my bundles/copy tasks are pretty hefty