0

我有一个 gulp 任务,它打开一个 index.html 文件并用其他内容替换两个构建/块。我正在使用“gulp-html-replace”:“^1.6.0”

这些块之一未正确执行替换。

这是gulp 任务

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/'));
})

这是需要替换的html块:

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

这是结果

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

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

如您所见,替换会注入新文本,但不会完全删除现有文本。

有人可以帮我弄清楚这是为什么吗?

谢谢

4

1 回答 1

2

如果源文件已经在目标文件夹中,这似乎发生在我身上。我会确保您没有将 index.html 文件放在捆绑任务之前的 dist 文件夹中的任务。

于 2016-06-15T13:29:53.187 回答