gulp-html-replace icon indicating copy to clipboard operation
gulp-html-replace copied to clipboard

Allow for tasks with special characters in name

Open jaythomas opened this issue 8 years ago • 0 comments
trafficstars

Thanks for the clever tool!

I'm using extract-text-webpack-plugin to generate a manifest file:

{
  "app.css": "app.bundle.8974f7041fb37318bbde0e39d3c9e2d1.css",
  "app.css.map": "app.bundle.8974f7041fb37318bbde0e39d3c9e2d1.css.map",
  "app.js": "app.bundle.fa373866e4cc4051adb3.js",
  "app.js.map": "app.bundle.fa373866e4cc4051adb3.js.map"
}

to pipe into gulp-html-replace like this:

const manifest = require('./manifest.json')
gulp
  .src('.app/index.html')
  .pipe(gulpHtmlReplace(manifest))
  .pipe(gulp.dest('dist/index.html'))

But it seems it doesn't like the .'s in the filenames because my index.html never changes:

<!-- build:app.css -->
<link rel="stylesheet" href="app.css">
<!-- endbuild -->

<!-- build:app.js -->
<script src="app.js"></script>
<!-- endbuild -->

However, if I manually remove the "." from the manifest filenames and the task names in the html (so that they both read like <!-- build:appcss -->) then it does its job:

<link rel="stylesheet" href="app.bundle.8974f7041fb37318bbde0e39d3c9e2d1.css">
<script src="app.bundle.fa373866e4cc4051adb3.js"></script>

I couldn't see anything in the readme mentioning special characters. Is this a bug?

As a workaround I could always strip special characters out of the generated manifest but this isn't ideal since I don't know what could break the tasks besides just periods.

Thanks for any help.

jaythomas avatar Jun 15 '17 21:06 jaythomas