-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·163 lines (127 loc) · 4.57 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
151
152
153
154
155
156
157
158
159
160
161
// this is a little Node program, running on a Node server
// require() will look inside of a folder and get information, similar to import
// NOTE: gulpfile.js must be in the main directory
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var minifyCss = require('gulp-minify-css');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var jade = require('gulp-jade');
var plumber = require('gulp-plumber');
////////////////////////////////////////////
// JADE COMPILE
////////////////////////////////////////////
gulp.task('jade', function() {
var jade_locals = {};
// using src = ./*.jade causes index.layout.jade to also compile which we don't want... unless we have multiple main directory files... in which case we do use ./*.jade
// otherwise use src = ./index.jade if there aren't other jade files in ./ (i.e. contact.jade, about.jade, etc.)
return gulp.src('./index.jade')
.pipe(plumber())
.pipe(jade({
locals: jade_locals,
pretty: true
}))
.pipe(gulp.dest('./'))
});
////////////////////////////////////////////
// END JADE COMPILE
////////////////////////////////////////////
////////////////////////////////////////////
// SASS COMPILE
////////////////////////////////////////////
gulp.task('sass', function () {
return gulp.src('css/*.scss')
.pipe(plumber())
.pipe(sass({
'sourcemap=none':true,
'errLogToConsole':true
}))
.pipe(concat('style.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
// .pipe(minifyCss({compatibility: 'ie8'}))
.pipe(gulp.dest('css/'))
.pipe(browserSync.stream());
});
////////////////////////////////////////////
// END SASS COMPILE
////////////////////////////////////////////
////////////////////////////////////////////
///// PLUGIN COMPILE
///////////////////////////////////////////////
/*
* COMMENT
*
*/
gulp.task('plugin-compile-not-mini', function () {
return gulp.src('css/partials/360main.scss')
.pipe(plumber())
.pipe(sass({
'sourcemap=none':true,
'errLogToConsole':true
}))
.pipe(concat('360main.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
// .pipe(minifyCss({compatibility: 'ie8'}))
.pipe(gulp.dest('css/'))
.pipe(browserSync.stream());
});
gulp.task('plugin-compile-mini', function () {
return gulp.src('css/partials/360main.scss')
.pipe(plumber())
.pipe(sass({
'sourcemap=none':true,
'errLogToConsole':true
}))
.pipe(concat('360main.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(gulp.dest('css/'))
.pipe(browserSync.stream());
});
///////////////////////////////////////////////
///// END PLUGIN COMPILE
///////////////////////////////////////////////
////////////////////////////////////////////
// BROWSER SYNC
////////////////////////////////////////////
gulp.task('server', ['sass','jade','plugin-compile-not-mini','plugin-compile-mini'], function() {
browserSync.init({
server: "./",
});
gulp.watch("css/*.scss", ['sass','plugin-compile-not-mini','plugin-compile-mini']);
// to get SASS partials to trigger changes
// the SCSS partials need to be in their own folder because css/*.scss causes all of them to trigger in the same directory, in the order they currently are which messes up everything
gulp.watch("css/partials/*.scss", ['sass','plugin-compile-not-mini','plugin-compile-mini']);
gulp.watch('./*.jade',['jade']);
// to get jade partials to trigger changes
gulp.watch('includes/*.jade',['jade']);
// whenever the .js files change reload
gulp.watch("js/*.js").on('change', reload);
// whenever the .css file changes reload
gulp.watch("css/*.css").on('change', reload);
// whenever the .html file changes reload
gulp.watch("*.html").on('change', reload);
});
////////////////////////////////////////////
// END BROWSER SYNC
////////////////////////////////////////////
////////////////////////////////////////////
// DEFAULT
////////////////////////////////////////////
gulp.task('default', ['server'], function () {
// place everything in here in 'server'
});
////////////////////////////////////////////
// END DEFAULT
////////////////////////////////////////////