dowjones / gulp-bundle-assets

Create static asset (js, css) bundles from a config file: a common interface to combining, minifying, revisioning and more
MIT License
133 stars 36 forks source link

Add Gulp-Remember Into Bundle Flow #51

Open smschrader opened 9 years ago

smschrader commented 9 years ago

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

chmontgomery commented 9 years ago

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?

smschrader commented 9 years ago

@chmontgomery I like that, simple enough!

timelf123 commented 9 years ago

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