babel-html-inline

compiled inline javascript code with babel

Usage no npm install needed!

<script type="module">
  import babelHtmlInline from 'https://cdn.skypack.dev/babel-html-inline';
</script>

README

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