-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (55 loc) · 1.5 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
54
55
56
57
58
59
60
61
62
var gulp = require("gulp");
var sass = require("gulp-sass");
var sourcemaps = require("gulp-sourcemaps");
var autoprefixer = require("gulp-autoprefixer");
var ecstatic = require("ecstatic");
var http = require("http");
var browserSync = require("browser-sync").create();
var paths = {
scss: ["scss/main.scss"],
css: "css/"
};
gulp.task("serve", function() {
http.createServer(ecstatic({ root: __dirname })).listen(8000);
console.log("Listening on :8000");
});
// Static server
gulp.task("browser-sync", function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
gulp.task("build-sass", function() {
return gulp
.src(paths.scss)
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
.pipe(
autoprefixer({
browsers: ["last 2 versions"],
cascade: false
})
)
.pipe(sourcemaps.write(""))
.pipe(gulp.dest(paths.css))
.pipe(browserSync.stream());
});
// auto-inject into browsers
gulp.task("css-change", function() {
return (
gulp
.src("css/**/*.css")
// .pipe(sass())
.pipe(gulp.dest("css"))
.pipe(browserSync.stream())
);
});
gulp.task("watch", function() {
// gulp.watch("scss/**/*.scss", ["build-sass"]);
gulp.watch("*.html").on("change", browserSync.reload);
// gulp.watch("css/**/*.css").on("change", browserSync.reload);
gulp.watch("css/**/*.css", ["css-change"]);
});
gulp.task("default", ["watch", /* "build-sass", */ "serve", "browser-sync"]);