This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
115 lines (98 loc) · 3.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
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
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var gulpSequence = require('gulp-sequence').use(gulp);
var panini = require('panini');
var browserSync = require('browser-sync').create();
var del = require('del');
var sassPaths = [
'bower_components/normalize.scss/sass',
'bower_components/foundation-sites/scss',
'bower_components/motion-ui/src'
];
gulp.task('panini', function() {
return gulp.src('pages/**/*{.html,.xml}')
.pipe(panini({
root: 'pages/',
layouts: 'layouts/',
partials: 'partials/',
helpers: 'helpers/',
data: 'data/'
}))
.pipe(gulp.dest('./build'));
});
// empty out the build folder
gulp.task('clean:build', function () {
return del([
'build/**/*'
]);
});
// copy any static assets into the build root
gulp.task('static', ['static:jquery', 'static:foundation', 'static:files']);
gulp.task('static:jquery', function () {
return gulp.src('./bower_components/jquery/dist/jquery.js')
.pipe(gulp.dest('./build/bower_components/jquery/dist'));
});
gulp.task('static:foundation', function () {
return gulp.src('./bower_components/foundation-sites/dist/js/foundation.js')
.pipe(gulp.dest('./build/bower_components/foundation-sites/dist/js'));
});
gulp.task('static:files', function () {
return gulp.src('./static/**/*')
.pipe(gulp.dest('./build'));
});
// refresh panini's helpers, templates
gulp.task('refresh', function () {
panini.refresh();
// gulp.start('taskname');
});
gulp.task('refreshBrowser', function () {
setTimeout(function() {
browserSync.reload();
}, 500); // wait for the filesystem to write
});
gulp.task('sass', function() {
return gulp.src('static/scss/embl-design-language-framework.scss')
.pipe($.sass({
includePaths: sassPaths,
outputStyle: 'compressed' // if css compressed **file size**
})
.on('error', $.sass.logError))
.pipe($.autoprefixer({
browsers: ['last 2 versions', 'ie >= 9']
}))
.pipe(gulp.dest('static/css'));
});
gulp.task('browser-sync', function() {
browserSync.init({
// proxy: "yourlocal.dev"
server: {
baseDir: './build/'
}
},function(){
// something you want to do
});
});
// gulp.task('dev', ['panini', 'browser-sync'], function() {
// var watcher = gulp.watch(['build/**/*'], function(event) {
// console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
// setTimeout(function() {
// browserSync.reload();
// }, 500); // wait for the filesystem to write
// });
// });
gulp.task('default', ['static', 'sass', 'panini', 'browser-sync'], function() {
gulp.watch(['scss/**/*.scss'], ['sass']);
var watcher = gulp.watch(['./{layouts,partials,data,pages,static}/**/*'], function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulpSequence(['refresh', 'static'], 'panini', 'refreshBrowser')(function (err) {
if (err) console.log(err)
})
});
});
gulp.task('clean', ['clean:build']); // purge ./build
gulp.task('init', ['clean:build', 'static']); // empty ./build and then make images, add static asssets
gulp.task('deploy', function() {
gulpSequence('static', 'panini')(function (err) {
if (err) console.log(err)
})
}); // for travis