compiler inline javascript with Babel and uglify
Using npm:
npm i -D babel-html-inline
or using yarn:
yarn add -D babel-html-inline
##options
key | value |
---|---|
needUglify | boolean (default false) |
require packages
const
gulp = require('gulp'),
babelHtml = require('babel-html-inline'),
htmlMin = require('gulp-htmlmin');
create task
//only babel in Html
gulp.task('babelHtml', () =>
gulp.src([srcDir + '/**/*.html'])
.pipe(babelHtml(options))
.pipe(gulp.dest(targetDir))
);
//used with html-min
gulp.task('htmlMin', function () {
let minOptions = {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: false,
removeEmptyAttributes: false,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true
};
gulp.src([srcDir + '/**/*.html'])
.pipe(babelHtml())
.pipe(htmlMin(minOptions))
.pipe(gulp.dest(targetDir));
});