const gulp = require('gulp');
const shell = require('gulp-shell');
const filter = require('gulp-filter-each');
const fileInclude = require('gulp-file-include');
const through = require('through2');
const prettyHtml = require('gulp-pretty-html');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
false;
const port = 3001;
gulp.task('build-template', async function () {
return new Promise((resolve) => {
gulp
.src('src/template/*.html')
.pipe(filter((content) => content.match(//gi)))
.pipe(
fileInclude({
prefix: '@@',
basepath: '@file',
})
)
.pipe(
through.obj(async function (file, enc, cb) {
let html = file.contents.toString();
// merge css link and scripts to head
const links = [];
const cssRegx = /\n/g;
html = html.replace(cssRegx, (match) => {
if (links.indexOf(match) === -1) {
links.push(match);
}
return '';
});
const scriptRegx = /