html: keep the inlined html during build

This commit is contained in:
Simone Caporale
2020-11-12 15:20:49 +01:00
committed by Shuanglei Tao
parent 3709de4cfa
commit 32c8a23655
2 changed files with 12 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
const { src, dest, task } = require("gulp");
const { src, dest, task, series } = require("gulp");
const clean = require('gulp-clean');
const gzip = require('gulp-gzip');
const inlineSource = require('gulp-inline-source');
@@ -33,13 +33,19 @@ const genHeader = (size, buf, len) => {
let fileSize = 0;
task('clean', () => {
return src('dist', {read: false, allowEmpty: true})
return src('dist', { read: false, allowEmpty: true })
.pipe(clean());
});
task('default', () => {
task('inline', () => {
return src('dist/index.html')
.pipe(inlineSource())
.pipe(rename("inline.html"))
.pipe(dest('dist/'));
});
task('default', series('inline', () => {
return src('dist/inline.html')
.pipe(through2.obj((file, enc, cb) => {
fileSize = file.contents.length;
return cb(null, file);
@@ -52,4 +58,5 @@ task('default', () => {
}))
.pipe(rename("html.h"))
.pipe(dest('../src/'));
});
}));

View File

@@ -13,6 +13,7 @@
"prestart": "gulp clean",
"start": "webpack serve",
"build": "NODE_ENV=production webpack && gulp",
"inline": "NODE_ENV=production webpack && gulp inline",
"check": "gts check",
"fix": "gts fix"
},