This repository has been archived by the owner on Dec 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (66 loc) · 1.91 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
'use strict';
var concat = require('gulp-concat');
var gulp = require('gulp');
var htmlmin = require('gulp-htmlmin');
var less = require('gulp-less');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var paths = {
html: 'src/html/**/*.html',
less: 'src/less/**/*.less',
js: 'src/js/**/*.js',
dist: 'dist/**/*'
};
// bundle js
gulp.task('js', ['templates'], function() {
return gulp.src(['src/js/index.js', 'tmp/templates.js'])
.pipe(concat('angular-slidedeck.js'))
.pipe(gulp.dest('dist'));
});
// bundle html templates via angular's templateCache
gulp.task('templates', function() {
return gulp.src(paths.html, {base: 'src/html'})
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(templateCache({
root: 'ngSlidedeckTemplates/',
standalone: true,
module: 'ngSlidedeckTemplates',
base: function(file) {
return file.relative;
}
}))
.pipe(gulp.dest('tmp'));
});
// minify js
gulp.task('js-min', ['js'], function() {
return gulp.src('dist/angular-slidedeck.js')
.pipe(rename('angular-slidedeck.min.js'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest('dist'));
});
// compile less to css
gulp.task('css', function() {
return gulp.src('src/less/index.less')
.pipe(less())
.pipe(rename('angular-slidedeck.css'))
.pipe(gulp.dest('dist'));
});
// minify css
gulp.task('css-min', ['css'], function() {
return gulp.src('dist/angular-slidedeck.css')
.pipe(rename('angular-slidedeck.min.css'))
.pipe(minifyCSS({restructuring: false}))
.pipe(gulp.dest('dist'));
});
// bower
gulp.task('bower', function() {
return gulp.src('bower.json.in')
.pipe(rename('bower.json'))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['js-min', 'css-min', 'bower']);