-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
250 lines (223 loc) · 6.04 KB
/
gulpfile.babel.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
import gulp from 'gulp';
import tslint from 'gulp-tslint';
import log from 'fancy-log';
import sass from 'gulp-sass';
import typescript from 'gulp-typescript';
import uglify from 'gulp-uglify-es';
import connect from 'gulp-connect';
import concat from 'gulp-concat';
import del from 'del';
import sassLint from 'gulp-sass-lint';
import typedoc from 'gulp-typedoc';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
var devbuild = false;
gulp.task('clean:dist', () => {
log('== Cleaning dist ==');
return del(['dist/**/*']);
});
gulp.task('clean:docs', () => {
log('== Cleaning docs ==');
return del(['docs/**/*']);
});
gulp.task('clean:temp', () => {
log('== Cleaning temp ==');
return del(['dist/js-pure/**/*.*']);
});
gulp.task('readme', () => {
log('== Assembling documentation files ==');
return gulp.src(['src/**/*.ts'])
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: 'commonjs',
target: 'es5',
excludeExternals: true,
includeDeclarations: true,
// Output options (see typedoc docs)
out: './docs',
// TypeDoc options (see typedoc docs)
name: 'enzmann',
theme: 'markdown',
plugins: ['mdFlavour bitbucket'],
ignoreCompilerErrors: false,
version: true,
}));
});
gulp.task('tslint', () => {
log('== Lintifying the ts files ==');
return gulp.src('src/**/*.ts')
.pipe(tslint({
formatter: 'verbose'
}))
.pipe(tslint.report({
emitError: false
}))
});
gulp.task('sasslint', () => {
log('== Lintifying the ts files ==');
return gulp.src(['src/scss/**/*.s+(a|c)ss'])
.pipe(sassLint({
options: {
formatter: 'stylish'
},
files: {ignore: 'src/scss/reset_author_richard_clark.scss'},
rules: {
'hex-length': [
2, // Severity 2 (error)
{
'style': 'long'
}
],
'no-color-literals': 0,
'no-ids': 0,
'no-mergeable-selectors': 0,
'no-vendor-prefixes': [
1, // Severity 1 (warning)
{
'excluded-identifiers': [
'webkit',
'moz'
]
}
]
}
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError());
});
gulp.task('html', () => {
log('== Copying index.html to dist ==');
return gulp.src('src/index.html')
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('font-awesome', () => {
log('== Copying font-awesome.css to dist ==');
return gulp.src('src/scss/font-awesome/font-awesome.min.css')
.pipe(gulp.dest('dist/css'))
.pipe(connect.reload());
});
gulp.task('loading-bar', () => {
log('== Copying loading-bar.min.css to dist ==');
return gulp.src('src/scss/loading-bar.min.css')
.pipe(gulp.dest('dist/css'))
.pipe(connect.reload());
});
gulp.task('loading-bar-script', () => {
log('== Copying loading-bar.min.js to dist ==');
return gulp.src('src/assets/libraries/loading-bar.min.js')
.pipe(gulp.dest('dist/js'))
.pipe(connect.reload());
});
gulp.task('font-awesome-fonts', () => {
log('== Copying font-awesome fonts to dist ==');
return gulp.src('src/scss/font-awesome/fonts/*.*')
.pipe(gulp.dest('dist/fonts'))
.pipe(connect.reload());
});
gulp.task('assets', () => {
log('== Copying index.html to dist ==');
return gulp.src('src/assets/**/*')
.pipe(gulp.dest('dist/assets'))
.pipe(connect.reload());
});
gulp.task('typescript', () => {
log('== Transmogrifying ts to js ==');
return gulp.src('src/**/*.ts')
.pipe(typescript({
noImplicitAny: true,
sourceMap: true,
module: "commonjs",
skipLibCheck: true,
target: 'ESNext'
}))
.on('error', log)
.pipe(gulp.dest('dist/js-pure'));
});
gulp.task('bundle', () => {
log('== Bundling the js ==');
return browserify('dist/js-pure/index.js')
.on('error', log)
.bundle()
.on('error', log)
.pipe(source('bundle.js'))
.on('error', log)
.pipe(buffer())
.pipe(gulp.dest('dist/' + (devbuild ? 'js/' : 'js-pure/')))
});
gulp.task('fuglify', () => {
log('== Fuglifying the js ==');
return gulp.src('dist/js-pure/bundle.js')
.pipe(uglify())
.on('error', log)
.pipe(gulp.dest('dist/js'));
});
gulp.task('sass', () => {
log('== Converting scss to css ==');
return gulp.src([
'src/scss/reset_author_richard_clark.scss',
'src/scss/*.scss'
])
.pipe(sass({style: 'expanded'}))
.on('error', log)
.pipe(concat('styles.css'))
.on('error', log)
.pipe(gulp.dest('dist/css'))
.pipe(connect.reload());
});
gulp.task('scripts:reload', (callback) => {
gulp.series('clean:temp', 'typescript', 'bundle', 'fuglify', 'reload')(callback);
});
gulp.task('connect', () => {
log('== Opening live reload server ==');
return connect.server({
root: 'dist',
livereload: true
});
});
gulp.task('reload', () => {
log('== reloading ==');
return gulp.src('dist/index.html')
.pipe(connect.reload());
});
gulp.task('envSet', (callback) => {
devbuild = true;
callback();
});
gulp.task('watch', () => {
gulp.watch('src/assets/**/*', ['assets']);
gulp.watch('src/ts/**/*.ts', ['scripts:reload']);
gulp.watch('src/scss/**/*.scss', ['sass']);
gulp.watch('src/index.html', ['html']);
});
gulp.task('devbuild', gulp.series(
'clean:dist',
['tslint', 'sasslint'],
['assets', 'html', 'sass', 'loading-bar', 'font-awesome', 'font-awesome-fonts', 'typescript'],
'loading-bar-script',
'bundle'
));
gulp.task('build', gulp.series(
'clean:dist',
['tslint', 'sasslint'],
['assets', 'html', 'sass', 'loading-bar', 'font-awesome', 'font-awesome-fonts', 'typescript'],
'loading-bar-script',
'bundle',
'fuglify'
));
gulp.task('typedoc', gulp.series(
'clean:docs',
'readme'
));
gulp.task('lint', gulp.series(
['tslint', 'sasslint']
));
gulp.task('default', gulp.series(
'envSet',
'clean:dist',
['assets', 'html', 'sass', 'loading-bar', 'font-awesome', 'font-awesome-fonts', 'typescript'],
'loading-bar-script',
'bundle',
'connect'
));