Answer the question
In order to leave comments, you need to log in
Gulp: How to find lines in html file and put into array?
for example, the index.html file contains comments like
<!-- [path-file] module/name_module -->
<!-- [path-file] module/name_module2 -->
Answer the question
In order to leave comments, you need to log in
Found a solution
var insert = require('gulp-insert');
var rename = require("gulp-rename");
require('./html-concat-all');
module.exports = function (buildOptions) {
return gulp.task('html_path_to_json', ['html_concat_all'], function (cb) {
var src_contents = '{"src" : [';
return fsvinyl.src('./dev/*/index.html')
.pipe(insert.transform(function(contents, file) {
var regExp = /\[path-file\] ([A-Za-z0-9\-\_]+\/[A-Za-z0-9\-\_]+)/gim; // upd: добавил регулярку
var file_content = contents;
var str = file_content;
var re = regExp;
var res;
while ( (res = re.exec(str)) != null) {
gutil.log("result " + res[1]);
src_contents = src_contents + '"./markup/' + res[1] + '/*.{scss,sass,less,css}",';
}
src_contents = src_contents + '"!./**/_*.{scss,sass,less,css}"] }';
return src_contents;
}))
.pipe(rename(function (path) {
path.basename = "path_modules";
path.extname = ".json"
}))
.pipe(gulp.dest('./dev/'));
});
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question