-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
110 lines (92 loc) · 3.5 KB
/
Gulpfile.js
File metadata and controls
110 lines (92 loc) · 3.5 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
'use strict';
var gulp = require('gulp'),
cleanhtml = require('gulp-cleanhtml'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
stripdebug = require('gulp-strip-debug'),
uglify = require('gulp-uglify'),
zip = require('gulp-zip'),
bump = require('gulp-bump'),
del = require('del'),
usemin = require('gulp-usemin');
var appFolder = './app/';
gulp.task('usemin', function () {
return gulp.src(appFolder + '*.html')
.pipe(usemin({
css: [minifycss({root: appFolder + 'styles', keepSpecialComments: 0}), 'concat'],
js: [stripdebug(), uglify({outSourceMap: true}), 'concat'],
html: [cleanhtml()]
}))
.pipe(gulp.dest('build'));
});
//clean build directory
gulp.task('clean', function (cb) {
del([
'build/**'
], cb);
});
// bump versions on package/bower/manifest
gulp.task('bump', function () {
gulp.src(['./bower.json', './package.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
return gulp.src(appFolder + 'manifest.json')
.pipe(bump())
.pipe(gulp.dest('app'));
});
//copy static folders to build directory
gulp.task('copy', ['bump'], function () {
gulp.src(appFolder + 'icons/**')
.pipe(gulp.dest('build/icons'));
gulp.src(appFolder + '_locales/**')
.pipe(gulp.dest('build/_locales'));
return gulp.src(appFolder + 'manifest.json')
.pipe(gulp.dest('build'));
});
//run scripts through JSHint
gulp.task('jshint', function () {
return gulp.src([appFolder + 'scripts/**/*.js', 'Gulpfile.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('chromeManifest', function () {
var manifest = require(appFolder + 'manifest');
gulp.src(manifest.background.scripts.concat(['!bower_components/**']), {cwd: appFolder})
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest('build/scripts'));
for (var i = 0; i < manifest.content_scripts.length; i++) { // jshint ignore:line
gulp.src(manifest.content_scripts[i].js.concat(['!bower_components/**']), {cwd: appFolder}) // jshint ignore:line
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest('build/scripts'));
}
});
//copy vendor scripts
gulp.task('scripts', ['jshint'], function () {
gulp.src(appFolder + 'bower_components/angular/*.min.js')
.pipe(gulp.dest('build/bower_components/angular'));
gulp.src(appFolder + 'bower_components/angular-bootstrap-colorpicker/**/{*.min.css,*.png,*.min.js}')
.pipe(gulp.dest('build/bower_components/angular-bootstrap-colorpicker'));
gulp.src(appFolder + 'bower_components/bootstrap/dist/fonts/**')
.pipe(gulp.dest('build/bower_components/bootstrap/dist/fonts'));
gulp.src(appFolder + 'bower_components/bootstrap/dist/**/{*.min.css,*.min.js}')
.pipe(gulp.dest('build/bower_components/bootstrap/dist'));
gulp.src(appFolder + 'bower_components/jquery/dist/*.min.js')
.pipe(gulp.dest('build/bower_components/jquery/dist'));
return gulp.src(appFolder + 'bower_components/rangy-official/*.min.js')
.pipe(gulp.dest('build/bower_components/rangy-official'));
});
//build ditributable and sourcemaps after other tasks completed
gulp.task('zip', ['scripts', 'usemin', 'copy', 'chromeManifest'], function () {
var pkg = require('./package.json'),
manifest = require('./build/manifest.json'),
distFileName = pkg.name + '-v' + manifest.version + '.zip';
return gulp.src(['build/**'])
.pipe(zip(distFileName))
.pipe(gulp.dest('dist'));
});
//run all tasks after build directory has been cleaned
gulp.task('default', ['clean'], function () {
gulp.start('zip');
});