-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
98 lines (78 loc) · 2.82 KB
/
gulpfile.js
File metadata and controls
98 lines (78 loc) · 2.82 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
90
91
92
93
94
95
96
97
98
'use strict';
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
inject = require("gulp-inject"),
del = require('del');
gulp.task('default', function() {
gulp.start('app');
});
gulp.task('app', function() {
gulp.start('app-addtracking','app-styles', 'app-scripts', 'app-images', 'app-move');
});
gulp.task('watch', function() {
// Watch .scss files
gulp.watch('app/**/*.scss', ['app-styles']);
// Watch .html files
gulp.watch('app/**/*.html', ['app-move']);
// Watch .js files
gulp.watch('app/**/*.js', ['app-scripts']);
// Watch image files
gulp.watch('app/images/**/*', ['app-images']);
// Create LiveReload server
livereload.listen();
// Watch any files in dist/, reload on change
gulp.watch(['dist/**']).on('change', livereload.changed);
});
gulp.task('app-move',function(){
// the base option sets the relative root for the set of files,
// preserving the folder structure
gulp.src(['app/bower_components/**/*','app/css/fonts/**/*','app/views/**/*','app/404.html'], { base: 'app/' })
.pipe(gulp.dest('dist/'));
});
gulp.task('app-addtracking',function(){
// injects optional tracking code if present
gulp.src('./app/index.html')
.pipe(inject(gulp.src(['./app/tracking/*.html']), {
starttag: '<!-- inject:tracking:{{ext}} -->',
transform: function (filePath, file) {
// return file contents as string
return file.contents.toString('utf8')
}
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('app-styles', function() {
return gulp.src('app/css/main.scss')
.pipe(sass({ style: 'expanded' }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('dist/css'));
});
gulp.task('app-scripts', function() {
return gulp.src('app/scripts/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('app-images', function() {
return gulp.src('app/images/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('dist/images'));
});
gulp.task('app-clean', function(cb) {
del(['dist/css', 'dist/js', 'dist/images','dist/bower_components','dist/iconic','dist/views','dist/index.html','dist/404.html'], cb);
});