forked from wangshijun/angular-echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (62 loc) · 1.69 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
'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var browserSync = require('browser-sync');
/**
* Run a webserver (with LiveReload)
*/
gulp.task('server', function() {
plugins.connect.server({
root: '.',
fallback: './index.html',
port: 8080,
livereload: true
});
});
/**
* Keep multiple browsers & devices in sync when building websites.
*/
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
/**
* Watching file change & rebuild
*/
gulp.task('watch', function () {
gulp.watch(['src/**/*.js', 'docs/**/*.[js,html]'], ['build']);
});
/**
* build Tasks
*/
gulp.task('build', function () {
// cleanup previous builds
gulp.src('dist/*.js', {read: false})
.pipe(plugins.clean());
// build js
gulp.src(['src/directive.js', 'src/util.js', 'src/theme.js', 'src/theme/*.js'])
.pipe(plugins.removeUseStrict())
.pipe(plugins.concat('angular-echarts.js'))
.pipe(plugins.wrap('(function () {<%= contents %>})();'))
.pipe(gulp.dest('dist'))
.pipe(plugins.rename({ suffix: '.min'}))
.pipe(plugins.uglify({ outSourceMap: true, mangle: true, report: 'gzip' }))
.pipe(plugins.size({ showFiles: true }))
.pipe(gulp.dest('dist'));
});
/**
* developing: rebuild after coding
*/
gulp.task('default', ['build', 'browser-sync', 'watch', 'server']);
/**
* publish: build then bump version
*/
gulp.task('publish', ['build'], function () {
// bump bower, npm versions
gulp.src(['package.json', 'bower.json'])
.pipe(plugins.bump())
.pipe(gulp.dest('.'));
});