-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
104 lines (86 loc) · 2.75 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// *************************************
//
// Rafters
// -> Stupid simple template builder
//
// *************************************
'use strict';
// -------------------------------------
// Plugins
// -------------------------------------
var gulp = require("gulp");
var autoprefixer = require("gulp-autoprefixer");
var connect = require("gulp-connect");
var file = require("gulp-file");
var ghPages = require("gulp-gh-pages");
var nunjucksRender = require("gulp-nunjucks-render");
var plumber = require("gulp-plumber");
var sass = require("gulp-sass");
var webpack = require("gulp-webpack");
// -------------------------------------
// Server
// -------------------------------------
gulp.task("connect", function() {
connect.server({
root: "build",
livereload: true
});
});
// -------------------------------------
// Tasks
// -------------------------------------
// ----- Assets ----- //
gulp.task("files", function() {
gulp.src("./source/assets/files/**/*")
.pipe(plumber())
.pipe(gulp.dest("./build/assets/files/"))
.pipe(connect.reload());
});
gulp.task("images", function() {
gulp.src("./source/assets/images/**/*")
.pipe(plumber())
.pipe(gulp.dest("./build/assets/images/"))
.pipe(connect.reload());
});
gulp.task("styles", function() {
gulp.src("./source/assets/stylesheets/*.sass")
.pipe(plumber())
.pipe(sass({outputStyle: 'compressed'}).on("error", sass.logError))
.pipe(autoprefixer())
.pipe(gulp.dest("./build/assets/stylesheets/"))
.pipe(connect.reload());
});
gulp.task("scripts", function() {
gulp.src("./source/assets/javascripts/**/*.js")
.pipe(plumber())
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest("./build/assets/javascripts/"))
.pipe(connect.reload());
});
gulp.task("template", function() {
gulp.src("./source/**/*.html")
.pipe(plumber())
.pipe(nunjucksRender({
path: ["./source/shared"]
}))
.pipe(gulp.dest("./build"))
.pipe(connect.reload());
});
gulp.task("watch", ["files", "images", "styles", "scripts", "template"], function() {
gulp.watch(["./source/**/*.html"], ["template"]);
gulp.watch(["./source/assets/files/**/*"], ["files"]);
gulp.watch(["./source/assets/images/**/*"], ["images"]);
gulp.watch(["./source/assets/javascripts/**/*"], ["scripts"]);
gulp.watch(["./source/assets/stylesheets/**/*"], ["styles"]);
});
// ----- Default ----- //
gulp.task("default", ["connect", "watch"]);
// -------------------------------------
// Tasks
// -------------------------------------
gulp.task('deploy', function() {
file('CNAME', 'demo.syllabusapp.com')
.pipe(gulp.dest('./build'));
return gulp.src('./build/**/*')
.pipe(ghPages());
});