-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
89 lines (80 loc) · 2.74 KB
/
gulpfile.js
File metadata and controls
89 lines (80 loc) · 2.74 KB
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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var cssmin = require('gulp-cssmin');
var angularHtmlify = require('gulp-angular-htmlify');
var htmlmin = require('gulp-htmlmin');
var ngHtml2js = require('gulp-ng-html2js');
var livereload = require('gulp-livereload');
var paths = {
scripts: ['./src/js/**/*.js'],
deps: [
// "bower_components/angular-strap/dist/modules/tooltip.min.js",
// "bower_components/angular-strap/dist/modules/tooltip.tpl.min.js",
"bower_components/angular-strap/dist/modules/parse-options.min.js",
"bower_components/angular-strap/dist/modules/dimensions.min.js"
],
templates: ['./src/templates/**/*.html'],
styles: ['./src/scss/**/*.{scss,css}']
};
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
return gulp.src(paths.scripts)
.pipe(concat('angularjssearchbox.js'))
.pipe(gulp.dest('build'))
.pipe(uglify())
.pipe(concat('angularjssearchbox.min.js'))
.pipe(gulp.dest('build'));
});
gulp.task('templates', function () {
return gulp.src(paths.templates)
.pipe(angularHtmlify())
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true
}))
.pipe(ngHtml2js({
moduleName: 'angularjssearchbox',
prefix: 'templates/',
declareModule: false
}))
.pipe(concat('angularjssearchbox.tpl.js'))
.pipe(gulp.dest('build'))
.pipe(uglify())
.pipe(concat('angularjssearchbox.tpl.min.js'))
.pipe(gulp.dest('build'));
});
gulp.task('styles', function () {
return gulp.src(paths.styles)
.pipe(sass())
.pipe(concat('angularjssearchbox.css'))
.pipe(gulp.dest('build'))
.pipe(cssmin())
.pipe(concat('angularjssearchbox.min.css'))
.pipe(gulp.dest('build'));
});
gulp.task('deps', function () {
return gulp.src(
paths.deps.concat([
'build/angularjssearchbox.js',
'build/angularjssearchbox.tpl.js'
])
)
.pipe(concat('angularjssearchbox.deps.js'))
.pipe(gulp.dest('build'))
.pipe(uglify())
.pipe(concat('angularjssearchbox.deps.min.js'))
.pipe(gulp.dest('build'));
});
gulp.task('serve', function(next) {
livereload.listen({port: 1234});
});
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.styles, ['styles']);
gulp.watch(paths.templates, ['templates']);
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['serve', 'scripts', 'templates', 'styles', 'deps', 'watch']);