-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (58 loc) · 1.8 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
const { dest, series, src, watch } = require('gulp');
const del = require('del');
const eslint = require('gulp-eslint');
const log = require('fancy-log');
const prettier = require('gulp-prettier');
const gulpWebpack = require('webpack-stream');
const webpackCompiler = require('webpack');
const webpackConfig = require('./webpack.config')
function bundle() {
log('Running bundler');
return src('src/widget.ts')
.pipe(gulpWebpack(webpackConfig, webpackCompiler, function(err, stats) { }))
.pipe(dest('dist/'));
}
function clean() {
log(`Cleaning up 'dist' directory`);
return del('./dist/**', { force: true });
}
function format() {
log('Formatting widget.html|js|json');
return src('dist/widget.{html,json}')
.pipe(
prettier({
arrowParens: 'always',
tabWidth: 4,
quoteProps: 'consistent',
singleQuote: true,
printWidth: 100,
useTabs: false,
})
)
.pipe(dest('dist/'));
}
function lint() {
log('Linting TypeScript files');
return src('src/**/*.ts')
.pipe(
eslint({
configFile: '.eslintrc.json',
})
)
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function move() {
log(`Moving widget.html|json to 'dist' directory`);
return src('src/widget.{html,json,css}').pipe(dest('dist/'));
}
function watchFiles() {
log('Watching widget.html|json|scss and *.ts');
watch('src/widget.{html,json,css}', move);
watch('src/**/*.ts', exports.default);
}
exports.bundle = bundle;
exports.clean = clean;
exports.lint = lint;
exports.watch = series(lint, clean, bundle, move, format, watchFiles);
exports.default = series(lint, clean, bundle, move, format);