-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
36 lines (32 loc) · 1.05 KB
/
Gulpfile.js
File metadata and controls
36 lines (32 loc) · 1.05 KB
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
const gulp = require("gulp");
const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");
const cleanCSS = require("gulp-clean-css");
const rename = require("gulp-rename");
const browserSync = require("browser-sync").create();
gulp.task("serve", ["scss"], function() {
browserSync.init({
server: "./"
});
gulp.watch("scss/*.scss", ["scss"]).on("change", browserSync.reload);
gulp.watch("*.html").on("change", browserSync.reload);
});
gulp.task("scss", function() {
return gulp
.src("scss/*.scss")
.pipe(sass().on('error', function(err) {
browserSync.notify(err.message, 5000); // Display error in the browser
this.emit('end'); // Prevent gulp from catching the error and exiting the watch process
}))
.pipe(
autoprefixer({
browsers: ["last 2 versions"],
cascade: false
})
)
.pipe(cleanCSS({ compatibility: "ie8" }))
.pipe(rename("main.min.css"))
.pipe(gulp.dest("./css"))
.pipe(browserSync.stream());
});
gulp.task("default", ["serve"]);