forked from mavoweb/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (65 loc) · 1.89 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
63
64
65
66
67
68
69
70
71
/*
Build file to concat & minify files, compile SCSS and so on.
npm install gulp gulp-util gulp-uglify gulp-rename gulp-concat gulp-sourcemaps gulp-babel gulp-sass gulp-autoprefixer --save-dev
*/
// grab our gulp packages
var gulp = require("gulp");
var rename = require("gulp-rename");
var sass = require("gulp-sass");
var autoprefixer = require("gulp-autoprefixer");
var sourcemaps = require("gulp-sourcemaps");
var notify = require("gulp-notify");
var fileinclude = require("gulp-file-include");
gulp.task("sass", function() {
gulp.src(["src-css/*.scss", "!**/_*.scss"])
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(autoprefixer({
browsers: ["last 2 versions"],
cascade: false
}))
.pipe(rename({ extname: ".css" }))
.pipe(sourcemaps.write("maps"))
.pipe(gulp.dest("dist"));
return gulp.src(["**/*.scss", "!node_modules/**", "!src-css/*.scss"])
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(autoprefixer({
browsers: ["last 2 versions"],
cascade: false
}))
.pipe(rename({ extname: ".css" }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."))
.pipe(notify({
message: "Sass done!",
onLast: true
}));
});
gulp.task("update", function() {
gulp.src(["../mavo/.eslintrc.json"]).pipe(gulp.dest("."));
});
gulp.task("html", function() {
gulp.src(["**/*.tpl.html"])
.pipe(fileinclude({
basepath: "../mavo.io/templates/",
context: {
webRoot: "//mavo.io"
}
}).on("error", function(error) {
console.error(error);
}))
.pipe(rename({ extname: "" }))
.pipe(rename({ extname: ".html" }))
.pipe(gulp.dest("."))
.pipe(notify({
message: "HTML done!",
onLast: true
}));
});
gulp.task("watch", function() {
gulp.watch(["../mavo/.eslintrc.json"], ["update"]);
gulp.watch(["**/*.scss"], ["sass"]);
gulp.watch(["**/*.tpl.html", "../mavo.io/templates/*.html"], ["html"]);
});
gulp.task("default", ["sass"]);