-
Notifications
You must be signed in to change notification settings - Fork 89
/
Gulpfile.js
53 lines (48 loc) · 1.05 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
var gulp = require('gulp');
var requirejs = require('gulp-requirejs');
var uglify = require('gulp-uglify');
var runSequence = require('run-sequence');
var rename = require('gulp-rename');
gulp.task('requirejs', function() {
return requirejs({
baseUrl: 'public/res',
name: 'main',
out: 'main.js',
mainConfigFile: 'public/res/main.js',
// optimize: 'uglify2', // 压缩
inlineText: true,
paths: {
mathjax: 'empty:'
},
excludeShallow: [
'css/css-builder',
'less/lessc-server',
'less/lessc'
]
})
.pipe(rename({ suffix: '-v2' }))
.pipe(gulp.dest('./public/res-min/'))
// 压缩
.pipe(uglify({
output: {
beautify: false,
indent_level: 1
}
}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/res-min/'));
});
gulp.task('minify',function() {
return gulp.src('./public/res-min/main-v2.js')
.pipe(uglify({
output: {
beautify: false,
indent_level: 1
}
}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./public/res-min/'));
});
gulp.task('default', function(cb) {
runSequence('requirejs');
});