-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
58 lines (49 loc) · 1.58 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
var packageInfo = require('./package.json'),
version = packageInfo.version,
gulp = require('gulp'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
minifyCss = require('gulp-minify-css'),
requireConfig = require('./build.json'),
rjs = require('gulp-requirejs'),
replace = require('gulp-replace'),
insert = require('gulp-insert'),
sequence = require('run-sequence'),
uglify = require('gulp-uglify'),
clean = require('gulp-clean'),
codeVersion = 'var appVersion="' + version + '";',
codeCopyRight = "/**\n" + packageInfo.copyright + " " + packageInfo.author +"\n\n" + packageInfo.description + "\n */\n",
paths = {
sass: ['./css/**/*.scss']
};
gulp.task('sass', function() {
gulp.src('./css/main.scss')
.pipe(sass())
.pipe(gulp.dest('./css/'))
.pipe(minifyCss())
.pipe(gulp.dest('./css/'));
});
gulp.task('requirejs', function() {
return rjs(requireConfig)
.pipe(gulp.dest('./'));
});
gulp.task('test', function() {
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
});
gulp.task('build-clean', function() {
return gulp.src('js/main.min.js', {read: false})
.pipe(clean());
});
gulp.task('compress', function() {
gulp.src('./js/main.min.js')
.pipe(uglify())
.pipe(insert.prepend(codeVersion))
.pipe(insert.prepend(codeCopyRight))
.pipe(gulp.dest('./js/'));
});
gulp.task('build', function(done) {
sequence('build-clean','requirejs', 'compress', done);
});
gulp.task('default', ['build', 'sass']);