gulp-html-replace not replacing entire block

1.2k views Asked by At

I have a gulp task that opens an index.html file and replaces two build/block with other content. I am using "gulp-html-replace": "^1.6.0"

One of these blocks is not performing the replace correctly.

Here is the gulp task:

gulp.task("html:bundle", ['html:clean', 'html:copy'], function () {
    gulp.src('./src/index.html')
    .pipe(htmlReplace({
        'APPJS': '/DesktopModules/regentsigns-app/dist/app.min.js'
    }))
    .pipe(gulp.dest('dist/'));
})

Here is the html block that needs to be replaced:

<!-- build:APPJS -->
<script>System.import('app').catch(function (err) { console.error(err); });</script>
<!-- endbuild -->

Here is the result:

<script src="/DesktopModules/regentsigns-app/dist/app.min.js"></script>

stem.import('app').catch(function (err) { console.error(err); });</script>
<!-- endbuild -->

As you can see, the replace injects the new text but does not fully remove the existing text.

Can someone help me figure out why this is?

Thanks

1

There are 1 answers

2
user6469847 On BEST ANSWER

This seem to occur for me if the source file was already in the destination folder. I would make sure you don't have a task that is placing your index.html file in the dist folder before your bundle task.