Created
August 16, 2018 20:01
-
-
Save Cool-Programmer/acc0c3e8c805f39dc3ed17316d1a6b39 to your computer and use it in GitHub Desktop.
gulpfile.js for bootstrap 4
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
npm init | |
npm i gulp browser-sync gulp-sass --save-dev | |
npm i bootstrap jquery popper.js --save |
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
const gulp = require("gulp"); | |
const browserSync = require("browser-sync").create(); | |
const sass = require("gulp-sass"); | |
// Compile sass and inject | |
gulp.task("sass", () => { | |
return gulp.src(["node_modules/bootstrap/scss/bootstrap.scss", "src/scss/*.scss"]) | |
.pipe(sass()) | |
.pipe(gulp.dest("src/css")) | |
.pipe(browserSync.stream()); | |
}); | |
// Move the js files to /src/js dir | |
gulp.task("js", () => { | |
return gulp.src(["node_modules/bootstrap/dist/js/bootstrap.min.js", "node_modules/jquery/dist/jquery.min.js", "node_modules/popper.js/dist/umd/popper.min.js"]) | |
.pipe(gulp.dest("src/js")) | |
.pipe(browserSync.stream()); | |
}); | |
// Static server + watching scss/html | |
gulp.task("serve", ["sass"], () => { | |
browserSync.init({ | |
server: "./src" | |
}); | |
gulp.watch(["node_modules/bootstrap/scss/bootstrap.scss", "src/scss/*.scss"], ["sass"]); | |
gulp.watch("src/*.html").on("change", browserSync.reload); | |
}); | |
gulp.task("default", ["js", "serve"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment