Inline all
<script>
,<link>
and<img>
tags that contain theinline
attribute with inline-source.
<!-- located at src/html/index.html -->
<html>
<head>
<!-- inline src/js/inlineScript.js -->
<script src="https://github.com/fmal/gulp-inline-source/raw/master/./js/inlineScript.js" inline></script>
</head>
<body>
</body>
</html>
// located at src/js/inlineScript.js
function test() {
var foo = 'lorem ipsum';
return foo;
}
Output:
<html>
<head>
<script>function test(){var a="lorem ipsum";return a}</script>
</head>
<body>
</body>
</html>
$ npm install gulp-inline-source --save-dev
var gulp = require('gulp');
var inlinesource = require('gulp-inline-source');
gulp.task('inlinesource', function () {
return gulp.src('./src/*.html')
.pipe(inlinesource())
.pipe(gulp.dest('./out'));
});
Optionally, you can provide some options through an options object:
var gulp = require('gulp');
var inlinesource = require('gulp-inline-source');
gulp.task('inlinesource', function () {
var options = {
compress: false
};
return gulp.src('./src/*.html')
.pipe(inlinesource(options))
.pipe(gulp.dest('./out'));
});