gulp-inline-html
v0.0.2
Published
inline js & css into html file
Downloads
4
Maintainers
Readme
gulp-inline-html
A gulp plugin to inline js&css files into html file.
Usage
Firstly, install gulp-inline-html
as a development dependency:
npm install gulp-inline-html --save
Then, add it into your gulpfile.js
:
concat all files according to each directory:
const inlineHtml = require("gulp-inline-html");
const gulpIf = require('gulp-if');
const babel = require('gulp-babel');
const autoprefixer = require('gulp-autoprefixer')
function fileType(extname) {
extname = (extname[0] === '.' ? '' : '.') + extname
return function (file) {
return path.extname(file.path) === extname
}
}
var isHtml = fileType('html')
var isJs = fileType('js')
var isCss = fileType('css')
gulp.src("./src/**/*")
//dosth with js and css
.pipe(gulpIf(isJs, babel()))
.pipe(gulpIf(isCss, autoprefixer({browsers: ['> 5%']})))
.pipe(inlineHtml())
.pipe(gulp.dest("build"));
Parameters
disabledTypes
Type: Array
Default: []
To disable which file type not inline into html file.