-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (50 loc) · 1.48 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
var gulp = require('gulp');
var gulpsync = require('gulp-sync')(gulp);
var htmlmin = require('gulp-htmlmin');
var cssnano = require('gulp-cssnano');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var embedTemplates = require('gulp-angular-embed-templates');
var del = require('del');
var Q = require('q');
var source = __dirname + '/src/';
var output = __dirname +'/dist/';
// removes all files from 'dist'
gulp.task('clean', function() {
var deferred = Q.defer();
del(output + '**/*', {dot: true}, function() {
deferred.resolve();
});
return deferred.promise;
});
// minify HTML templates
gulp.task('templates', function() {
return gulp.src([source + 'js/templates/**/*.html'])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest(output + 'templates/'));
});
// minify javascript
gulp.task('js', function() {
return gulp.src([source + 'js/angular-toolbar.js'])
.pipe(embedTemplates())
.pipe(uglify({mangle:false}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(output));
});
// minify css
gulp.task('css', function() {
return gulp.src([source + 'css/angular-toolbar.css'])
.pipe(cssnano({discardComments: {removeAll: true}}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(output));
});
// group all build tasks
gulp.task('build', gulpsync.sync([
//'clean',
// 'templates',
'js',
'css'
]));