-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
230 lines (202 loc) · 5.12 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
var gulp = require('gulp');
var KarmaServer = require('karma').Server;
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var minify = require('gulp-minify');
var watch = require('gulp-watch');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var postcssCustomSelectors = require('postcss-custom-selectors');
var browserSync = require('browser-sync').create();
var Docma = require('docma');
var removeCode = require('gulp-remove-code');
var buildOrder = require('./buildOrder.js');
sass.compiler = require('node-sass');
// Compile sass into CSS & auto-inject into browsers
exports['homepage:sass'] = function() {
return gulp.src("./homepage/scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("./homepage/css"))
.pipe(browserSync.stream());
};
exports['serve:homepage'] = function () {
browserSync.init({
server: {
baseDir: "./homepage/",
routes: {
"/stepback/": "./homepage/"
}
}
});
gulp.watch("./homepage/docs/**/*.html").on('change', browserSync.reload);
}
function concatJS () {
return gulp
.src(buildOrder)
.pipe(sourcemaps.init())
.pipe(concat('sb.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/'));
}
function buildSCSS () {
return gulp.src('./src/**/*.scss')
.pipe(postcss({modules: true}))
.pipe(
postcss([
postcssCustomSelectors({})
])
)
.pipe(sourcemaps.init())
.pipe(sass.sync().on('error', sass.logError))
.pipe(concat('sb.css'))
.pipe(gulp.dest('./dist'))
.pipe(sourcemaps.write())
.pipe(browserSync.stream());
};
function minifyJS() {
return gulp.src(['./dist/sb.js'])
.pipe(removeCode({ debug: false }))
.pipe(minify({
noSource: true
}))
.pipe(gulp.dest('dist'))
}
const buildJS = gulp.series(concatJS, minifyJS);
exports.buildJS = buildJS;
function buildDocs() {
return Docma.create()
.build({
"src": ["./src/namespaces.js"].concat(buildOrder.concat([
"./README.md"
])),
"assets": {
"./": ["./dist", "./playground"]
},
"dest": "./homepage/docs",
"clean": true,
"debug": false,
"jsdoc": {
"encoding": "utf8",
"recurse": true,
"pedantic": false,
"access": null,
"package": null,
"module": false,
"undocumented": false,
"undescribed": false,
"ignored": false,
"hierarchy": true,
"relativePath": null,
"filter": null,
"sort": "grouped",
"allowUnknownTags": false,
"plugins": []
},
"markdown": {
"gfm": true,
"tables": true,
"breaks": false,
"pedantic": false,
"sanitize": false,
"smartLists": true,
"smartypants": false,
"xhtml": false,
"tasks": true,
"emoji": true
},
"app": {
"title": "StepBack Documentation",
"meta": null,
"entrance": "content:readme",
"routing": "path",
"base": "/stepback/docs/"
},
"template": {
"options": {
"title": {
"label": "StepBack v1.0.0"
},
"contentView": {
"bookmarks": "h1,h2,h3",
"faLibs": "all"
},
"navbar": {
"enabled": true,
"fixed": true,
"dark": false,
"animations": true,
"menu": [
{
"iconClass": "fas fa-book",
"label": "API Reference",
"href": "./api/"
},
{
"iconClass": "fas fa-play",
"label": "Playground",
"href": "./playground/index.html",
"target": "_self"
}
]
},
"sidebar": {
"itemsOverflow": "shrink",
"itemsFolded": false,
"badges": true
},
"symbols": {
"meta": true,
"params": "table",
"props": "table"
}
}
}
})
.catch(error => {
console.log(error);
});
}
exports["build:docs"] = buildDocs;
/**
* Run test once and exit
*/
function test(done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
}
exports.test = test;
/**
* Watch for file changes and re-run tests on each change
*/
function tdd(done) {
const server = new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: false
}, done);
server.start();
server.on('run_complete', function (browsers, result) {
if (!result.error) {
console.log('Tests did not fail, building new package.')
build();
}
});
};
exports.tdd = tdd;
const build = gulp.series(buildSCSS, buildJS);
exports.build = build;
exports.default = build;
exports.watch = gulp.series(build, function watchSrc() {
browserSync.init({
server: {
baseDir: "./homepage",
},
ghostMode: false,
port: 3001
});
watch(buildOrder.concat(['./src/**/*.scss', './src/**/*.js']), function(cb) {
build(cb);
});
watch('./dist/sb.js').on('change', browserSync.reload);
});