-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·62 lines (53 loc) · 1.46 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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var tsify = require('tsify');
var uglify = require('gulp-uglify');
// var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
// 监控源码更改
var livereload = require('gulp-livereload');
var paths = {
pages: ['src/*.html'],
css: ['src/*.css'],
ts: ['src/ts/*.ts']
};
gulp.task('tsc', function () {
browserify({
basedir: '.',
debug: true,
entries: ['src/ts/init.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist'))
.pipe(livereload());
});
gulp.task('jsmin', function () {
gulp.src(['dist/*.js'])
.pipe(uglify({
mangle:{except:['require','exports','module','$']}
}))
.pipe(gulp.dest('dist/jsmin'));
});
gulp.task('copy-css', function () {
gulp.src(paths.css)
.pipe(gulp.dest('dist'))
.pipe(livereload());
});
gulp.task('copy-html', function () {
gulp.src(paths.pages)
.pipe(gulp.dest('dist'))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch(paths.pages, ['copy-html']);
gulp.watch(paths.css, ['copy-css']);
gulp.watch(paths.ts, ['tsc']);
});
gulp.task('default', ['copy-html', 'copy-css', 'tsc', 'watch']);
gulp.task('fuck', ['jsmin']);