-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
150 lines (133 loc) · 3.61 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Gulp
var gulp = require('gulp');
// Plugins
var twig = require('gulp-twig');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var prefix = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var browserSync = require("browser-sync");
var filter = require('gulp-filter');
var rimraf = require('gulp-rimraf');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
// Paths
var paths = {
scripts: ['bower_components/jquery/dist/jquery.js',
'bower_components/fastclick/lib/fastclick.js',
'bower_components/modernizr/modernizr.js',
'bower_components/foundation/js/foundation/foundation.js',
'bower_components/foundation/js/foundation/foundation.equalizer.js',
'bower_components/foundation/js/foundation/foundation.orbit.js',
'bower_components/foundation/js/foundation/foundation.topbar.js',
'bower_components/foundation/js/foundation/foundation.clearing.js',
'assets/js/*.js'
],
images: ['assets/img/**'],
fonts: ['assets/fonts/**']
};
// Wipe off build folder
gulp.task('clean', function() {
return gulp.src(['Build', 'build'], {
read: false
})
.pipe(rimraf());
});
// Jade to HTML
gulp.task('twig', function() {
gulp.src(['**/*.twig', '!./{node_modules/**, node_modules}'])
.pipe(plumber())
.pipe(twig({
pretty: true
}))
.pipe(gulp.dest('build/'))
.pipe(browserSync.reload({
stream: true
}));
});
// Compile Sass
gulp.task('sass', function() {
gulp.src(['assets/scss/main.scss', '!**/.DS_Store'])
.pipe(plumber())
.pipe(sass({
includePaths: ['bower_components/foundation/scss',
'assets/scss'
],
//outputStyle: 'compressed',
errLogToConsole: true,
sourceComments: 'normal'
}))
.pipe(prefix(
"last 1 version", "> 1%", "ie 8", "ie 7"
))
//.pipe(minifycss())
.pipe(gulp.dest('build/assets/css'));
//.pipe(filter('build/assets/css/*.css')) // Filtering stream to only css files
/* .pipe(browserSync.reload({
stream: true
}));*/
});
// Uglify JS
gulp.task('uglify', function() {
gulp.src(paths.scripts)
.pipe(plumber())
//.pipe(browserify())
//.pipe(uglify({
// outSourceMap: false
//}))
.pipe(concat("main.js"))
.pipe(gulp.dest('build/assets/js'))
});
// Compress images
gulp.task('imagemin', function() {
gulp.src(paths.images, ['!**/.DS_Store'])
.pipe(plumber())
//.pipe(imagemin())
.pipe(gulp.dest('build/assets/img'));
});
// Copy all static assets
gulp.task('copyFonts', function() {
return gulp.src(paths.fonts)
.pipe(gulp.dest('build/assets/fonts'));
});
// Livereload
gulp.task('listen', function() {
browserSync({
server: {
baseDir: "./build/"
},
});
});
gulp.task('wait', function(end) {
//wait(5000);
end();
});
gulp.task('reload', function() {
browserSync.reload();
});
gulp.task('refresh-sass', function() {
setTimeout(function reload() {
runSequence('wait', 'sass', 'reload');
}, 5000);
});
// Watch files
gulp.task('watch', function(event) {
gulp.watch(['twigs/**','**/*.twig'],
[browserSync.reload]);
gulp.watch('assets/scss/*.scss', ['refresh-sass']);
//gulp.watch(paths.images, ['imagemin', browserSync.reload]);
//gulp.watch(paths.fonts, ['copyFonts', browserSync.reload]);
gulp.watch(paths.scripts, ['uglify', browserSync.reload]);
});
gulp.task('default', function(callback) {
runSequence('wait', 'clean', ['sass',
//'twig',
'imagemin',
'copyFonts',
'uglify'
],
'listen',
'watch');
});