-
-
Save kolyasademetrio/f7cf2136d40fec93e33471c7c04b1b58 to your computer and use it in GitHub Desktop.
inject js as async (custom way)
This file contains 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
//install | |
//npm i gulp-inject group-array@0.3.1 | |
var inject = require('gulp-inject'); | |
//inject libs js | |
gulp.task('inject:js', function() { | |
return gulp.src('./app/*.html') | |
.pipe(inject(gulp.src('./app/js/libs.min.js', { //inject more than one js in capturedbyanastasiia | |
read: false //just inject no read | |
}), { | |
relative: true, //if true inject:js/libs.min.js, if false inject:/app/js/libs.min.js | |
transform: filepath => `<script src="${filepath}" async></script>` | |
})) | |
.pipe(gulp.dest('./dist')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment