Я пытаюсь заменить путь файла CSS в index.html с помощью Gulp. Проблема в том, что у меня есть несколько проектов с разными именами тем, и путь к исходному файлу отличается в дистрибутиве.
index.html
<link href="app/style/themes/dark/theme.css" id="hmi-theme" rel="stylesheet" />
В моем дистрибутиве тема копируется в что-то вроде src\projects\project\app\style\themes
расстояние/index.html
<link href="[set the path here/]app/style/themes/dark/theme.css" id="hmi-theme" rel="stylesheet" />
Вот попытка с помощью gulp-find найти URL-адрес в index.html:
var gulp = require('gulp');
var find = require('gulp-find');
var replace = require('gulp-replace');
gulp.task('templates', function(){
gulp.src(['index.html'])
.pipe(find(/app\/style\/themes\/([^"]*)/g))
.pipe(gulp.dest('file.txt'));
Это работает, у меня есть значение в файле назначения. Но можно ли использовать это значение с gulp-replace для изменения значения в файле HTML?
Я пробовал также что-то вроде:
.pipe(replace(/app\/style\/themes\/([^"]*)/g, "dist/" + find(/app\/style\/themes\/([^"]*)/g)))
Но значение в index.html было:
dist/[object Object]