-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (89 loc) · 2.81 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
"use strict"
var gulp = require("gulp")
// ━━━━━━━━━━━━━━━━━━━━━━
// Linting for TypeScript
// ━━━━━━━━━━━━━━━━━━━━━━
var tslint = require("gulp-tslint")
gulp.task("tslint", function() {
return gulp.src([
"./src/**/*.ts",
"./test/**/*.ts"
])
.pipe(
tslint({
configuration: "./tslint.json",
fix: true
})
)
.pipe(tslint.report())
})
// ━━━━━━━━━━━━━━━━━━━━━━
// Build JS/TS
// ━━━━━━━━━━━━━━━━━━━━━━
var exec = require('child_process').exec
gulp.task('buildjs', function (cb) {
exec('npm run rollup', function (err, stdout, stderr) {
console.log(stdout)
console.log(stderr)
cb(err)
})
})
// ━━━━━━━━━━━━━━━━━━━━━━
// Transepile Sassy CSS
// ━━━━━━━━━━━━━━━━━━━━━━
function exceptionLog (error) {
console.log(error.toString())
this.emit('end')
}
var sass = require('gulp-sass')
gulp.task('styles', function () {
return gulp.src('./styles/styles.scss')
.pipe(sass.sync({
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(gulp.dest('./docs/assets/styles/'))
.on('error', exceptionLog)
})
// ━━━━━━━━━━━━━━━━━━━━━━
// Convert settings
// ━━━━━━━━━━━━━━━━━━━━━━
var Hjson = require('gulp-hjson')
gulp.task('convert-hjson-to-json', function() {
return gulp.src(['./hjson/**/*'])
.pipe(Hjson({ to: 'json' }))
.pipe(gulp.dest('./docs/assets/json/'))
})
// ━━━━━━━━━━━━━━━━━━━━━━
// Make settings with env
// ━━━━━━━━━━━━━━━━━━━━━━
var replace = require('gulp-replace')
var env = require('node-env-file')
env('.env')
gulp.task('make-settings', function() {
return gulp
.src(['./settings.hjson'])
.pipe(replace('%%GOOGLE_MAP_API_KEY%%', process.env.GOOGLE_MAP_API_KEY))
.pipe(replace('%%GOOGLE_ANALYTICS_ID%%', process.env.GOOGLE_ANALYTICS_ID))
.pipe(gulp.dest('./hjson/'))
})
// ━━━━━━━━━━━━━━━━━━━━━━
// Default
// ━━━━━━━━━━━━━━━━━━━━━━
gulp.task("default",
gulp.series(
'make-settings',
"convert-hjson-to-json",
"tslint",
gulp.parallel("buildjs", "styles")
)
)
// ━━━━━━━━━━━━━━━━━━━━━━
// Launch test server
// ━━━━━━━━━━━━━━━━━━━━━━
var connect = require('gulp-connect')
gulp.task('connect', function() {
connect.server({
root: './docs',
livereload: true
})
})