forked from winds-mobi/winds-mobi-client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpFile.js
72 lines (65 loc) · 2.34 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sass = require('gulp-sass');
var browserify = require('browserify');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var cdnizer = require('gulp-cdnizer');
gulp.task('js', function () {
var b = browserify(
['static/web/js/app.js', 'static/web/js/controllers.js', 'static/web/js/services.js'],
{
debug: true,
// => true for discify: './node_modules/disc/bin/discify static/web/js/windmobile.js > discify.html'
fullPaths: false
}
);
return b.bundle()
// http://stackoverflow.com/questions/23161387/catching-browserify-parse-error-standalone-option
.on('error', function (err) {
gutil.log(err);
this.emit('end');
})
.pipe(source('windmobile.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(gutil.env.production ? uglify() : gutil.noop())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('static/web/js/'));
});
gulp.task('sass', function () {
gulp.src('src/scss/*.*')
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('static/web/css/'));
});
gulp.task('html', function () {
gulp.src('src/html/**/*.html')
.pipe(gutil.env.production ?
cdnizer({
defaultCDNBase: '//files-windsmobi.netdna-ssl.com',
allowRev: true,
allowMin: true,
files: [
'/static/web/js/windmobile.js',
'/static/web/css/windmobile.css',
'/static/web/manifest.json',
'/static/web/img/*.*'
]
}) :
gutil.noop())
.pipe(gulp.dest('static/web/'));
});
gulp.task('watch', function () {
gulp.watch(['static/web/js/app.js', 'static/web/js/controllers.js', 'static/web/js/services.js',
'static/web/locale/*.js'], ['js']);
gulp.watch('src/scss/*.*', ['sass']);
gulp.watch('src/html/**/*.html', ['html']);
});
gulp.task('default', ['js', 'sass', 'html']);