-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (58 loc) · 2.07 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
// Gulp tasks
// Load plugins
var gulp = require('gulp'),
watch = require('gulp-watch'),
prefix = require('gulp-autoprefixer'),
minifyCSS = require('gulp-minify-css'),
sass = require('gulp-sass'),
size = require('gulp-size'),
rename = require('gulp-rename'),
css = require('css'),
browserSync = require('browser-sync'),
browserReload = browserSync.reload,
concat = require('gulp-concat');
// Task that compiles scss files down to css
gulp.task('pre-process', function(){
gulp.src('./scss/site.scss')
.pipe(watch(function(files) {
return files.pipe(sass())
.pipe(size({gzip: false, showFiles: true, title:'un-prefixed css'}))
.pipe(size({gzip: true, showFiles: true, title:'un-prefixed gzipped css'}))
.pipe(prefix())
.pipe(size({gzip: false, showFiles: true, title:'prefixed css'}))
.pipe(size({gzip: true, showFiles: true, title:'prefixed css'}))
.pipe(gulp.dest('css'))
.pipe(minifyCSS())
.pipe(rename('site.min.css'))
.pipe(gulp.dest('./css/'))
.pipe(size({gzip: false, showFiles: true, title:'minified css'}))
.pipe(size({gzip: true, showFiles: true, title:'minified css'}))
.pipe(browserSync.reload({stream:true}));
}));
});
// Initialize browser-sync which starts a static server also allows for
// browsers to reload on filesave
gulp.task('browser-sync', function() {
browserSync.init(null, {
server: {
baseDir: "./"
},
port: 3000
});
});
// Function to call for reloading browsers
gulp.task('bs-reload', function () {
browserSync.reload();
});
/*
DEFAULT TASK
• Process sass then auto-prefixes and lints outputted css
• Starts a server on port 3000
• Reloads browsers when you change html or sass files
*/
gulp.task('default', ['pre-process', 'bs-reload', 'browser-sync'], function(){
gulp.start('pre-process');
gulp.watch('sass/*/*.scss', ['pre-process']);
gulp.watch('css/site.min.css', ['bs-reload']);
gulp.watch(['*.html'], ['bs-reload']);
});