-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
93 lines (77 loc) · 2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//npm install gulp-clean gulp-autoprefixer gulp-minify-css gulp-csslint gulp-sourcemaps gulp-jshint jshint-stylish gulp-uglify
var gulp = require('gulp');
var clean = require('gulp-clean');
var autoprefixer = require('gulp-autoprefixer');
var cssmin = require('gulp-minify-css');
var csslint = require('gulp-csslint');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
gulp.task('default', ['dev']);
gulp.task('dev', ['js:dev', 'css', 'manifest', 'icons', 'lib', 'html'], function(){
gulp.watch('extension/src/**/*.js', ['js:dev']);
gulp.watch('extension/styles/**/*.css', ['css']);
gulp.watch('extension/manifest.json', ['manifest']);
gulp.watch('extension/icons/**/*', ['icons']);
gulp.watch('extension/lib/**/*', ['lib']);
gulp.watch('extension/src/**/*.html', ['html']);
});
gulp.task('build', ['js:build', 'css', 'manifest', 'icons', 'lib', 'html']);
gulp.task('clean', function(){
return gulp.src('build/*', {read:false})
.pipe(clean());
})
gulp.task('clean-js', function(){
return gulp.src('build/src/**/*.js', {read:false})
.pipe(clean());
})
gulp.task('clean-css', function(){
return gulp.src('build/styles/**/*.css', {read:false})
.pipe(clean());
})
gulp.task('js:dev', ['clean-js'], function(){
return gulp.src('extension/src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(uglify())
.pipe(gulp.dest('build/src'));
});
gulp.task('js:build', ['clean-js'], function(){
return gulp.src('extension/src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.pipe(uglify())
.pipe(gulp.dest('build/src'));
});
gulp.task('css', ['clean-css'], function(){
return gulp.src('extension/styles/**/*.css')
.pipe(csslint())
.pipe(csslint.reporter())
.pipe(autoprefixer({
browsers: ['last 4 Chrome versions'],
cascade: false
}))
.pipe(sourcemaps.init())
.pipe(cssmin())
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/styles'));
});
//TODO: Do more with manifest/icons/libs/html
gulp.task('manifest', function(){
return gulp.src('extension/manifest.json')
.pipe(gulp.dest('build'));
});
gulp.task('icons', function(){
return gulp.src('extension/icons/**/*')
.pipe(gulp.dest('build/icons'));
});
gulp.task('lib', function(){
return gulp.src('extension/lib/**/*')
.pipe(gulp.dest('build/lib'));
});
gulp.task('html', function(){
return gulp.src('extension/src/**/*.html')
.pipe(gulp.dest('build/src'));
})