Last active
January 14, 2016 16:57
-
-
Save LoicGoyet/89c4fd5318d0f0db0dec to your computer and use it in GitHub Desktop.
Basic usage of gulp-inject plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var inject = require('gulp-inject'); | |
gulp.task('inject', function () { | |
var target = gulp.src('index.html'); | |
// It's not necessary to read the files (will speed up things), we're only after their paths: | |
var sources = gulp.src(['style.css', 'script.js'], {read: false}); | |
return target.pipe(inject(sources)) | |
.pipe(gulp.dest('result.html')); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My index</title> | |
<!-- inject:css --> | |
<!-- endinject --> | |
</head> | |
<body> | |
<!-- inject:js --> | |
<!-- endinject --> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My index</title> | |
<!-- inject:css --> | |
<link rel="stylesheet" href="/style.css"> | |
<!-- endinject --> | |
</head> | |
<body> | |
<!-- inject:js --> | |
<script src="/script.js"></script> | |
<!-- endinject --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment