jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

Error when src and dest are the same when using multi level directories #235

Open codedbypaul opened 7 years ago

codedbypaul commented 7 years ago

If you use gulp-useref with the same src and dest directories you get an error, although the files do actually get modified correctly.

My task is:

gulp.task('private:app:useref', () => {
      return gulp.src('./dist/**/*.html')
        .pipe(plugins.plumber())
        .pipe(plugins.useref())
        .pipe(gulp.dest('./dist/'));
    })

With this code in the html:

<!-- build:css /styles/style.min.css-->
<!-- inject:css-->
<link rel="stylesheet" href="/styles/style.css">
<!-- endinject-->
<!-- endbuild-->

The error message I get for each subdirectory html file is:

 Error: Error: File not found with singular glob: /dist/about/styles/style.css

Yet when you look at the index file in /about/ useref has done the right thing.

<link rel="stylesheet" href="/styles/style.min.css">

If you set gulp.dest to a different directory no error is reported.

Any ideas on how to make the error go away while still using the same src and dest directories?