-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (80 loc) · 2.17 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
const gulp = require('gulp');
const stylus = require('gulp-stylus');
// const nib = require('nib');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const handlebars = require('gulp-compile-handlebars');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const postcss = require('gulp-postcss');
const quash = require('postcss-quash');
const autoprefixer = require('autoprefixer');
gulp.task('browser-sync', function() {
browserSync.init( {
server: {
baseDir: "./build"
},
port: "3000",
open: false
});
});
// CSS
gulp.task('css', function() {
return gulp.src('src/stylesheets/style.styl')
.pipe(stylus())
.pipe(gulp.dest('build/stylesheets'))
.pipe(reload({stream: true}));
});
// PostCSS
// gulp.task('postcss', function () {
// const processors = [
// quash
// ];
// return gulp.src('./build/stylesheets/style.css')
// .pipe(postcss(processors))
// .pipe(gulp.dest('./test'));
// });
// JS
gulp.task('scripts', function() {
return gulp.src('src/js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('build/js'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('build/js'))
.pipe(reload({stream:true}));
});
gulp.task('vendor', function() {
return gulp.src('src/js/vendor/*.js')
.pipe(gulp.dest('build/js/vendor'));
});
// Templates
gulp.task('templates', function() {
const templateData = {
title: 'Fremen'
};
const options = {
ignorePartials: true,
batch: ['./src/views'],
helpers: {
capitals: function(str){
return str.toUpperCase();
}
}
};
return gulp.src('src/views/*.html')
.pipe(handlebars(templateData, options))
.pipe(gulp.dest('build/'))
.pipe(reload({stream:true}));
});
// Initial build
gulp.task('build', ['css', 'scripts', 'vendor', 'templates']);
// Watch
gulp.task('watch', function() {
gulp.watch('src/stylesheets/**/*.styl', ['css']);
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('src/views/**/*.html', ['templates']);
});
// Development
gulp.task('default', ['build', 'browser-sync', 'watch']);