gulp html minification error

in the gulp trying to perform html minification in the build

Code:

gulp.task('html',function(){
  return gulp.src('app/**/*.html')

   .pipe($.useref.assets({searchPath: '{.tmp,app}'}))
   // Concatenate And Minify JavaScript
    .pipe($.if('*.js', $.uglify({
     preserveComments: 'some'
    })))
    // Concatenate And Minify Styles
    .pipe($.if('*.css', $.csso()))
    .pipe($.useref.restore())
    .pipe($.useref())
    // Update Production Style Guide Paths
    .pipe($.replace('styles/main.css'))
    // Minify Any HTML Output Files
    .pipe(gulp.dest'dist'))
    .pipe($.size({title: 'html'}));
});

Error:

TypeError: Uncaught, unspecified "error" event.
    at TypeError (<anonymous>)
    at Transform.emit (events.js:74:15)
    at Transform.onerror (node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:558:12)
    at Transform.emit (events.js:95:17)
    at Transform.<anonymous> (index.js:80:42)
    at Array.forEach (native)
    at Transform.<anonymous> (index.js:68:35)
    at Array.for Each (native)
    at Transform.<anonymous> (index.js:46:36)
    at Array.forEach (native)

has anyone came across this issue , please suggest how to fix this

Thanks Sundar

Upvotes: 2

Views: 720

Answers (1)

Miha-ha
Miha-ha

Reputation: 36

upgrade gulp-useref:

npm remove gulp-useref && npm i gulp-useref --save-dev

Upvotes: 2

Related Questions