-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
57 lines (42 loc) · 1.22 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
const rollup = require('gulp-better-rollup');
const sourcemaps = require('gulp-sourcemaps');
const resolvePlugin = require('rollup-plugin-node-resolve');
const browserSync = require('browser-sync');
const paths = {
js: './src/**/*.ts',
output: './dist',
build: './build'
};
function build() {
const buildResult = gulp.src(paths.js)
.pipe(tsProject(ts.reporter.fullReporter(true)));
return buildResult.js
.pipe(gulp.dest(paths.build))
}
function dist() {
return gulp.src(paths.build + '/**/*.js')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(rollup({plugins: [resolvePlugin()]}, 'iife'))
.pipe(sourcemaps.write(''))
.pipe(gulp.dest(paths.output));
}
function reload() {
browserSync.reload();
return Promise.resolve();
}
function watch() {
browserSync.init({
server: {
baseDir: "./dist"
},
open: false
});
gulp.watch(paths.js, gulp.series('deploy', reload));
}
gulp.task(build);
gulp.task(dist);
gulp.task('deploy', gulp.series(build, dist));
gulp.task("watch", gulp.series('deploy', watch));