This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (44 loc) · 1.62 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* =============================================================================
@author: Kishan Nirghin
============================================================================= */
var gulp = require("gulp"),
gutil = require("gulp-util"),
sass = require("gulp-sass"),
autoprefixer = require("gulp-autoprefixer");
/* spawn a browsersync object (needed for automatic refreshing) */
var browserSync = require("browser-sync").create();
/* Watches scss folder for changes in scss files
* -> Recompiles scss into the corresponding folder
*/
gulp.task("build-css", function() {
return gulp.src("./src/scss/**/*.scss")
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(gulp.dest("./dist/css"));
});
/* Moves over the html files to the right folder */
gulp.task("build-html", function(){
return gulp.src("./src/**/*.html")
.pipe(gulp.dest("./dist"));
});
/* Creates a browsersync browser instance */
gulp.task("browserSync", function() {
browserSync.init({
server: {
baseDir: "./dist"
},
browser: "google chrome"
});
});
/* Start watching all
* - First compiles everything
* - Then sets up watchers for css
*/
gulp.task("watch", ["browserSync", "build-html", "build-css"], function(){
gulp.watch("./src/**/*.html", ["build-html"]);
gulp.watch("./dist/**/*.html", browserSync.reload);
gulp.watch("./src/scss/**/*.scss", ["build-css"]);
gulp.watch("./dist/css/**/*.css", browserSync.reload);
gulp.watch("gulpfile.js").on("change", () => process.exit(0));
});
gulp.task("build", ["build-html", "build-css"]);