gulp-cache-modified

1.0.0 • Public • Published

gulp-cache-modified

Provides a simple in-memory cache designed for incremental compilation when using something like nodemon.

Example

var cacheModified = require('gulp-cache-modified');

// Create an instance outside of a task so it can cache compiled files from
// build to build.

var cache = new cacheModified();

gulp.task('js', function() {

  return gulp.src('src/*.js'])

    // Call `updateSource` to allow the cache to look for modified files.

    .pipe(jsCache.updateSource())

    // If there are no modified files, the plugin will throw an error
    // with a specific message to abort the entire process.

    .on('error', function(err) {
      if (err.message !== 'no modified files') {
        // If there are no updates, gulp-cache-modified will throw an error
        // telling us so we can abort the pipeline.
        gutil.log(gutil.colors.red(err.message));
      }
    })

    // If there were modified files, *only* the modified ones are
    // passed along to here, so add any generated files and compile.

    .pipe(sourcemaps.init())
    .pipe(babel({
      modules: 'system',
      moduleIds: true, // necessary since we are going to concatenate
      keepModuleIdExtensions: true,
      optional: ["es7.comprehensions"],
    }))

    // Pass the compiled files to the cache.

    .pipe(cache.updateProcessed())

    // Now the cache will pass along *all* files, both cached and those just
    // compiled.  They'll be passed in the same order they were originally
    // passed to updateSource.

    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('build'));

Readme

Keywords

Package Sidebar

Install

npm i gulp-cache-modified

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mkleehammer