Last active
March 18, 2021 07:25
-
-
Save LoyEgor/bd8c51695e778d3a627e04973342236d 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 [email protected] | |
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