npm.io
1.0.4 • Published 5 years ago

babel-html-inline

Licence
MIT
Version
1.0.4
Deps
0
Size
2 kB
Vulns
0
Weekly
0

babel-html-inline

compiler inline javascript with Babel and uglify

Install

Using npm:

npm i -D babel-html-inline

or using yarn:

yarn add -D babel-html-inline

##options

key value
needUglify boolean (default false)

Using

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));
});

Keywords