-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
48 lines (40 loc) · 1.34 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
var gulp = require("gulp"),
sass = require("gulp-sass"),
rename = require("gulp-rename"),
cssmin = require("gulp-cssnano"),
prefix = require("gulp-autoprefixer"),
sourcemaps = require("gulp-sourcemaps");
var browserSync = require("browser-sync").create();
// Static Server + watching scss/html files
gulp.task("serve", function() {
browserSync.init({
server: "./public"
});
gulp.watch("source/style/**/*.scss", ["sass"]).on("change", browserSync.reload);
gulp.watch("public/*.html").on("change", browserSync.reload);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task("sass", function() {
return gulp.src("source/style/style.scss")
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("public/css"))
.pipe(browserSync.stream());
});
// Build the CSS for production
var sassOptions = {
outputStyle: "expanded"
};
var prefixerOptions = {
browsers: ["last 2 versions"]
};
gulp.task("build", function() {
return gulp.src("source/style/style.scss")
.pipe(sourcemaps.init())
.pipe(sass(sassOptions))
.pipe(prefix(prefixerOptions))
.pipe(rename("style.css"))
.pipe(gulp.dest("public/css"))
.pipe(cssmin())
.pipe(gulp.dest("public/css"))
});
gulp.task("dev", ["sass", "serve"]);