-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
87 lines (65 loc) · 1.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
var gulp = require("gulp");
var sass = require("gulp-sass");
var serve = require('gulp-serve');
var shell = require('gulp-shell');
var clean = require('gulp-clean');
var runSequence = require('run-sequence');
var request = require("request");
var fs = require('fs');
var config = require('dotenv').config()
// what goes where?
var buildSrc = "src";
var buildDest = "dist";
// cleanup the build output
gulp.task('init', function () {
// Look for the environment variables
if(process.env.URL) {
var siteEnv = {"rootURL" : process.env.URL};
} else {
var siteEnv = {"rootURL" : "https://twavatar.netlify.com"};
}
// save the status of our environment somewhere that our SSG can access it
fs.writeFile(buildSrc + "/site/_data/site.json", JSON.stringify(siteEnv), function(err) {
if(err) {
console.log(err);
}
});
});
// cleanup the build output
gulp.task('clean-build', function () {
return gulp.src(buildDest, {read: false})
.pipe(clean());
});
// local webserver for development
gulp.task('serve', serve({
root: [buildDest],
port: 8008,
}));
// Compile SCSS files to CSS
gulp.task("scss", function () {
gulp.src(buildSrc + "/scss/main.scss")
.pipe(sass({
outputStyle: "compressed"
}).on('error', sass.logError))
.pipe(gulp.dest(buildDest + "/css"))
});
/*
Run our static site generator to build the pages
*/
gulp.task('generate', shell.task('eleventy --config=eleventy.js'));
/*
Watch src folder for changes
*/
gulp.task("watch", function () {
gulp.watch(buildSrc + "/**/*", ["build"])
});
/*
Let's build thus sucker.
*/
gulp.task('build', function(callback) {
runSequence(
['clean-build','init'],
['generate', 'scss'],
callback
);
});