-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGulpfile.js
85 lines (72 loc) · 2.22 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
/*
This is an EXAMPLE gulpfile.js
You'll want to change it to match your project.
Find plugins at https://npmjs.org/browse/keyword/gulpplugin
*/
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var less = require('gulp-less');
var ngmin = require('gulp-ngmin');
var minifyHTML = require('gulp-minify-html');
var templates = require('gulp-angular-templatecache');
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
gulp.src('source/templates/**/*.html')
.pipe(minifyHTML({
empty: true,
spare: true,
quotes: true
}))
.pipe(templates('templates.js'))
.pipe(gulp.dest('source/js'));
gulp.src(['source/js/**/*.js', '!source/js/lib/**', 'source/js/templates.js'])
.pipe(concat("main.js"))
.pipe(ngmin())
.pipe(uglify())
.pipe(gulp.dest('build/js'));
// Copy vendor files
gulp.src(['source/lib/jquery/jquery.min.js','source/lib/angular/angular.min.js','source/lib/angular-route/angular-route.min.js'])
.pipe(concat("lib.js"))
.pipe(gulp.dest('build/js'));
gulp.src(['source/lib/**/*.css'])
.pipe(concat("lib.css"))
.pipe(gulp.dest('build/css/lib'));
});
gulp.task('less', function () {
gulp.src('source/less/main.less')
.pipe(less())
.pipe(gulp.dest('build/css'));
});
// Copy all static assets
gulp.task('copy', function() {
gulp.src('source/img/**')
.pipe(gulp.dest('build/img'));
gulp.src('source/index.html')
.pipe(gulp.dest('build'));
gulp.src('source/assets/fonts/**')
.pipe(gulp.dest('build/fonts'));
gulp.src('source/assets/misc/**')
.pipe(gulp.dest('build/misc'));
});
// The default task (called when you run `gulp`)
gulp.task('default', function() {
gulp.run('scripts', 'less', 'copy');
// Watch files and run tasks if they change
gulp.watch('source/js/**', function(event) {
gulp.run('scripts');
});
gulp.watch('source/less/**', function(event) {
gulp.run('less');
});
gulp.watch('source/**/*.html', function(event) {
gulp.run('copy','scripts');
});
gulp.watch([
'source/img/**',
'source/assets/fonts/**',
'source/assets/misc/**'
], function(event) {
gulp.run('copy');
});
});