forked from tkem/mopidy-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (91 loc) · 2.97 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
94
95
96
97
98
99
100
101
102
103
var bower = require('bower');
var cleanCss = require('gulp-clean-css');
var del = require('del');
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var rename = require ('gulp-rename');
var sass = require('gulp-sass');
var paths = {
'build': 'build/',
'css': 'www/css/',
'dist': 'mopidy_mobile/www/',
'images': 'www/images/',
'lib': 'www/lib/',
'sass': 'scss/'
};
gulp.task('install', function(cb) {
bower.commands.install()
.on('log', function(data) {
plugins.util.log('bower', plugins.util.colors.cyan(data.id), data.message);
})
.on('end', function() {
cb()
});
});
gulp.task('sass:images', function() {
return gulp.src('scss/**/*.png', {base: 'scss'})
.pipe(gulp.dest(paths.css));
});
gulp.task('sass', gulp.series('sass:images', function() {
return gulp.src('scss/[^_]*.scss')
.pipe(sass())
.on('error', sass.logError)
.pipe(gulp.dest(paths.css))
.pipe(cleanCss({keepSpecialComments: 0}))
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest(paths.css));
}));
gulp.task('jshint', function() {
return gulp.src(['www/app/**/*.js', 'merges/*/app/**/*.js'])
.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.jshint.reporter('default'))
.pipe(plugins.jshint.reporter('fail'));
});
gulp.task('uglify', function() {
return gulp.src(['www/app/**/*.js'])
.pipe(plugins.concat('mopidy-mobile.js'))
.pipe(plugins.uglify({mangle: false, compress: false}))
.pipe(plugins.rename({extname: '.min.js'}))
.pipe(gulp.dest(paths.build));
});
gulp.task('templates', function() {
return gulp.src('www/app/**/*.html')
.pipe(plugins.angularTemplatecache({module: 'app', root: 'app/'}))
.pipe(plugins.uglify())
.pipe(plugins.rename('templates.min.js'))
.pipe(gulp.dest(paths.build));
});
gulp.task('bundle', gulp.series(gulp.parallel('uglify', 'templates'), function() {
return gulp.src([
paths.lib + '/mopidy/dist/mopidy.min.js',
paths.lib + '/ionic/js/ionic.bundle.min.js',
paths.lib + '/messageformat/messageformat.js',
paths.lib + '/angular-translate/angular-translate.min.js',
paths.lib + '/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js',
paths.build + '/mopidy-mobile.min.js',
paths.build + '/templates.min.js'
]).pipe(plugins.concat('mopidy-mobile.bundle.min.js'))
.pipe(gulp.dest(paths.dist));
}));
gulp.task('dist', gulp.series(gulp.parallel('sass', 'bundle'), function() {
return gulp.src([
'www/css/*.min.css',
'www/css/**/*.png',
'www/app/**/*.gif',
'www/app/**/*.png',
'www/app/**/*.svg',
'www/lib/ionic/fonts/**',
], {base: 'www'})
.pipe(gulp.dest(paths.dist));
}));
gulp.task('clean', function() {
return del([
paths.build,
paths.css,
paths.dist + '{app,css,lib,*.min.js}'
]);
});
gulp.task('watch', gulp.series('sass', function() {
return gulp.watch(paths.sass, gulp.series('sass'));
}));
gulp.task('default', gulp.parallel('sass', 'jshint'));