-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
74 lines (63 loc) · 1.96 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
var gulp = require('gulp'),
gulpUtil = require('gulp-util'),
less = require('gulp-less'),
concat = require('gulp-concat'),
minifyCss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
templateCache = require('gulp-angular-templatecache'),
rename = require('gulp-rename'),
path = require('path'),
clean = require('gulp-clean'),
sourcemaps = require("gulp-sourcemaps");
var paths = {
scripts: ['src/js/*.module.js', 'src/js/*.js', 'build/templates/am-date-picker.tmpl.js'],
styles: 'src/less/*.less',
templates: 'src/templates/*.html',
images: 'src/img/**/*.svg'
};
gulp.task('less', function () {
return gulp.src(paths.styles)
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(minifyCss())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('dist/'));
});
gulp.task('images', function() {
return gulp.src(paths.images)
.pipe(gulp.dest('dist/images'))
});
gulp.task('tmpl:date-picker', function () {
return gulp.src('src/templates/*.html')
.pipe(templateCache('am-date-picker.tmpl.js', {
module: 'am.date-picker'
}))
.pipe(gulp.dest('build/templates'));
});
gulp.task('scripts', ['tmpl:date-picker'], function() {
return gulp.src(paths.scripts)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify().on('error', gulpUtil.log))
.pipe(concat('am-date-picker.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'));
});
gulp.task('clean-build', ['scripts'], function () {
return gulp.src('build', {read: false})
.pipe(clean());
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch('src/templates/*.html', ['scripts']);
gulp.watch(paths.styles, ['less']);
gulp.watch('src/less/*.less', ['less']);
gulp.watch(path.templates, ['tmpl:date-picker', 'scripts']);
});
gulp.task('default', [
'watch',
'images',
'less',
'scripts',
'clean-build'
]);