Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it me, or this doesn't work with gulp-filter? #60

Open
debuggerpk opened this issue Apr 5, 2016 · 1 comment
Open

is it me, or this doesn't work with gulp-filter? #60

debuggerpk opened this issue Apr 5, 2016 · 1 comment

Comments

@debuggerpk
Copy link

It used to work with version 2, updated to version 3, updated the task, The task i.e.

gulp.task('minify:dashboard', ['inject:dashboard'], function() {
  var assets;

  return gulp.src(paths.django.templates.root + '/__dashboard.html')
    .pipe($.replace('script src="{{ STATIC_URL }}dashboard', 'script src="compile'))

    .pipe($.useref({
      searchPath: '.'
    }))

    // versioning assets
    .pipe(indexHtmlFilter)
      .pipe($.buffer())
      .pipe($.rev())
      .pipe($.debug())
      .pipe(indexHtmlFilter.restore)

    // processing scripts
    .pipe(jsFilter)
      // .pipe($.uglify({
      //   preserveComments: $.uglifySaveLicense,
      //   compress: uglifyCompressOptions
      // }))
      .pipe($.size())
      .pipe(gulp.dest(paths.django.assets.dashboard + '/builds'))
      .pipe(jsFilter.restore)

    // updating references
    .pipe($.revReplace())
    // adding django static url reference
    .pipe($.replace('src="scripts', 'src="{{ STATIC_URL }}dashboard/builds/scripts'))
    .pipe(gulp.dest('compile/builds'));
});

This tasks works fine on its own, e.g.

gulp minify:dashboard

however, when i introduce a new task

gulp.task('minify', ['minify:common', 'minify:dashboard']);

the above task gulp minify gives me this

events.js:154
      throw er; // Unhandled 'error' event
      ^
Error: write after end
    at writeAfterEnd (/magneto/dashboard/node_modules/readable-stream/lib/_stream_writable.js:203:12)
    at StreamFilter.Writable.write (/magneto/dashboard/node_modules/readable-stream/lib/_stream_writable.js:239:20)
    at write (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at emitNone (events.js:80:13)
    at DestroyableTransform.emit (events.js:179:7)
    at emitReadable_ (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:448:10)
    at emitReadable (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:444:5)
    at readableAddChunk (/magneto/dashboard/node_modules/gulp-useref/node_modules/readable-stream/lib/_stream_readable.js:187:9)

the strange thing, i remove all the filters, i.e.

gulp.task('minify:dashboard', ['inject:dashboard'], function() {
  var assets;

  return gulp.src(paths.django.templates.root + '/__dashboard.html')
    .pipe($.replace('script src="{{ STATIC_URL }}dashboard', 'script src="compile'))

    .pipe($.useref({
      searchPath: '.'
    }))

    // versioning assets
    //.pipe(indexHtmlFilter)
      .pipe($.rev())
      .pipe($.debug())
      //.pipe(indexHtmlFilter.restore)

    // processing scripts
    //.pipe(jsFilter)
      // .pipe($.uglify({
      //   preserveComments: $.uglifySaveLicense,
      //   compress: uglifyCompressOptions
      // }))
      //.pipe($.size())
      //.pipe(gulp.dest(paths.django.assets.dashboard + '/builds'))
      //.pipe(jsFilter.restore)

    // updating references
    .pipe($.revReplace())
    // adding django static url reference
    .pipe($.replace('src="scripts', 'src="{{ STATIC_URL }}dashboard/builds/scripts'))
    .pipe(gulp.dest('compile/builds'));
});

then the task gulp minify works perfectly fine. Is it something wrong with gulp-filter package, or am i using it wrong?

@ermish
Copy link

ermish commented Oct 24, 2016

I had a similar issue using gulp-filter.
I believe you need to add the manifest option to revReplace() .
So:

.pipe($.revReplace())

becomes:

.pipe($.revReplace({ manifest: gulp.src('dist/manifestfile') })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants