Skip to content

Instantly share code, notes, and snippets.

@moehammoud
Last active May 10, 2017 22:58
Show Gist options
  • Save moehammoud/c945073fd18ac2dbcd0c0d7df91a6cef to your computer and use it in GitHub Desktop.
Save moehammoud/c945073fd18ac2dbcd0c0d7df91a6cef to your computer and use it in GitHub Desktop.
htmlbuild
{
"name": "play1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-htmlbuild": "^0.4.2"
}
}
var gulp = require('gulp');
gulp.task('default', function() {
// place code for your default task here
});
gulp.task('build', function () {
gulp.src(['./index.html'])
.pipe(htmlbuild({
// build js with preprocessor
js: htmlbuild.preprocess.js(function (block) {
// read paths from the [block] stream and build them
// ...
// then write the build result path to it
block.write('buildresult.js');
block.end();
})
}))
.pipe(gulp.dest('./build'));
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- htmlbuild:js -->
<script src="js/script1.js"></script>
<script src="js/script2.js"></script>
<!-- endbuild -->
</body>
</html>
{
"name": "play1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-htmlbuild": "^0.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment