forked from bowenliang123/SandwidchRequestModifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
128 lines (105 loc) · 3.21 KB
/
gulpfile.js
File metadata and controls
128 lines (105 loc) · 3.21 KB
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
'use strict';
// Load plugins
const gulp = require('gulp');
const clean = require('gulp-clean');
const zip = require('gulp-zip');
const babel = require("gulp-babel");
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
let getYYYYMMDDHHMM = () => {
let toXX = (input) => ((input < 10) ? ('0' + input) : input);
let date = new Date();
return `${date.getFullYear()}${toXX(date.getMonth() + 1)}${toXX(date.getDate())}${toXX(date.getHours())}${toXX(date.getMinutes())}`;
};
// 复制必要的文件
gulp.task('copyBower', ['clean'], ()=> {
return gulp.src([
//angular
'bower_components/angular/angular.min.js',
//angular-translate
'bower_components/angular-translate/angular-translate.min.js',
'bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js',
'bower_components/angular-cookies/angular-cookies.min.js',
'bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.min.js',
'bower_components/angular-translate-storage-local/angular-translate-storage-local.min.js',
//bootstrap
'bower_components/bootstrap/dist/**/*',
//font-awesome
'bower_components/font-awesome/css/**/*',
'bower_components/font-awesome/fonts/**/*',
//jquery
'bower_components/jquery/dist/**/*',
//ua-parser-js
'bower_components/ua-parser-js/dist/**/*',
//jquery-elastic
'bower_components/jquery-elastic/jquery.elastic.source.js',
], {'base': '.'})
.pipe(gulp.dest('dist/'));
});
// 复制必要的文件
gulp.task('copyNpm', ['clean'], ()=> {
return gulp.src([
//
//'node_modules//**/*',
], {'base': '.'})
.pipe(gulp.dest('dist/'));
});
// 复制必要的文件
gulp.task('copy', ['clean', 'copyBower'], ()=> {
return gulp.src([
'manifest.json',
'html/*',
'css/*',
// 'js/**/*',
//'bower_components/**/',
'img/*',
'locales/*.json'
], {'base': '.'})
.pipe(gulp.dest('dist/'));
});
// Clean
gulp.task('clean', () => {
return gulp.src([
'dist/',
'releases/'
], {read: false})
.pipe(clean());
});
// zip
gulp.task('zip', ['build'], ()=> {
return gulp.src('dist/**/*', {'base': '.'})
.pipe(zip('SandwidchRequester-' + getYYYYMMDDHHMM() + '.zip'))
.pipe(gulp.dest('releases'));
});
// babeljs
gulp.task('babeljs', ['clean', 'copy'], ()=> {
return gulp.src("js/**/*.js")
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest("dist/js"));
});
// Build
gulp.task('build', ['clean', 'copy', 'babeljs']);
// Default
gulp.task('default', ['watch']);
// Watch
gulp.task('watch', ['build'], () => {
gulp.watch([
//项目依赖单个文件
'manifest.json',
'gulpfile.js',
//应用逻辑
'css/**/*',
'html/**/*',
'img/**/*',
'js/**/*',
'locales/*',
//依赖库
'bower.json',
'package.json',
//'bower_components/**/*',
//'node_modules/',
], ['build']);
});