This repository has been archived by the owner on May 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
84 lines (79 loc) · 2.64 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
const gulp = require('gulp');
const coffee = require('gulp-coffee');
const babel = require('gulp-babel');
const log = require('fancy-log');
const postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const cssimport = require('gulp-cssimport');
const postcssGridKiss = require('postcss-grid-kiss');
const postcssCssVariables = require('postcss-css-variables');
const cssnano = require('cssnano');
const exec = require('child_process').exec;
const through2 = require('through2');
const gutil = require('gulp-util');
const plumber = require('gulp-plumber');
const path = require('path');
gulp.task('events', function(done) {
// Convert spreadsheet to events
gulp.src('./src/events.xlsm')
.pipe(plumber())
.on('end', () => log("Found sheet"))
.pipe(through2.obj((file, enc, cb) => {
exec("./generate_dialogue.py", (err, stdout, stderr) => {
if (err) { gutil.log(err); }
file.contents = new Buffer(stdout);
console.log(stderr);
cb(err, file);
});
}))
.on('end', () => log("Processed sheet"))
.pipe(rename("events.temp.coffee"))
.pipe(gulp.dest('./src/js/'))
.on('end', () => log("Converted events sheet to coffeescript"))
.on('end', () => done());
});
gulp.task('js', function(done) {
// Pipe any js files (should be none in final build)
gulp.src('./src/js/*.js')
.pipe(gulp.dest('./dist/'))
.on('end', () => log("Moved any JS files to dist"));
// Convert coffee files
gulp.src('./src/js/*.coffee', {sourcemaps: true})
.pipe(rename(function(path) {
if(path.basename === "events.temp") {
path.basename = "events";
};
}))
.pipe(coffee({bare: true}))
.on('end', () => log("Converted coffee to JS"))
.pipe(babel({presets: ['env']}))
.on('end', () => log("Piped coffee through Babel"))
.pipe(gulp.dest('./dist/'))
.on('end', () => done());
});
gulp.task('css', function(done) {
// Post-process, minify and concatenate css files
gulp.src('./src/css/root.css')
.pipe(cssimport())
.on('end', () => log("Resolving CSS imports"))
.pipe(postcss([
// postcssCssVariables(),
postcssGridKiss(),
// cssnano(),
]))
.on('end', () => log("Post-processing CSS"))
.pipe(rename("cluedo.css"))
.pipe(gulp.dest('./dist/'))
.on('end', () => done());
});
gulp.task('static', function(done) {
// Pipe images, html, json
gulp.src('./src/images/*.*')
.pipe(gulp.dest('./dist/'));
gulp.src('./src/*.html')
.pipe(gulp.dest('./dist/'));
gulp.src('./src/js/*.json')
.pipe(gulp.dest('./dist/'))
.on('end', () => done());
});
gulp.task('default', gulp.series('events','js','css','static'));