-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
99 lines (89 loc) · 3.05 KB
/
gulpfile.js
File metadata and controls
99 lines (89 loc) · 3.05 KB
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
// Gulpfile for Pattern Library
// Renders .scss files, uses Pleeease.io, doesn't stop gulp on error (gulp-plumber),
// -- notifies you if there are errors in your code (gulp-notify),
// -- & uses Browser Sync for livereload capability.
// Put your Sass (.scss) files in an "scss" directory in the root.
// -----------------------------------------------------
// Load all the dependencies
var gulp = require('gulp'),
scss = require('gulp-ruby-sass'),
plumber = require('gulp-plumber'),
notify = require("gulp-notify"),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync');
// Browser Sync
gulp.task('browser-sync', function() {
browserSync.init(null);
});
// Extracting and renaming Normalize CSS file from Bower components
gulp.task('bower-css', function(){
gulp.src([
'bower_components/normalize-css/normalize.css'
])
.pipe(rename({ prefix: '_'}))
.pipe(rename({ extname: '.scss' }))
.pipe(gulp.dest('scss/vendor'));
});
// SCSS task
// Compile Our Sass from the "scss" directory, run it through Pleeease and output it to "stylesheets".
// If there are any errors, gulp-notify will tell us
gulp.task('scss', function() {
gulp.src('scss/*.scss')
.pipe(scss({style: 'expanded'}))
.pipe(autoprefixer('last 4 versions', 'safari 5', 'ie 7', 'ie 8', 'ie 9', 'opera 12.1','ios 6', 'android 4'))
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(gulp.dest('stylesheets'))
.pipe(browserSync.reload({stream:true}))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('stylesheets'))
.pipe(browserSync.reload({stream:true}));
});
// Extracting Bower JS component files
gulp.task('bower-js', function(){
gulp.src([
'bower_components/svgeezy/svgeezy.js'
])
.pipe(gulp.dest('javascripts/vendor'));
});
// Javascript
gulp.task('js', function() {
return gulp.src(['javascripts/*.js', 'javascripts/**.js', 'javascripts/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('all.js'))
.pipe(gulp.dest('javascripts'))
.pipe(browserSync.reload({stream:true}))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('javascripts'))
.pipe(browserSync.reload({stream:true}));
});
// Auto-reload Templates
gulp.task('reload', function () {
gulp.src('views/**/*.html')
.pipe(browserSync.reload({stream:true}));
});
// Compress Image Task
gulp.task('image', function(){
gulp.src('images/**/*')
.pipe(imagemin())
.pipe(gulp.dest('images/'));
});
// Watch HTML, YML, and CSS
gulp.task('watch', function () {
gulp.watch(['**/*.html','**/*.yml'],['reload']);
gulp.watch([
'scss/*.scss',
'scss/**/*.scss'
],
['scss']);
});
// Use Sass, watch, & Browser Sync in Default Task
gulp.task('default', ['bower-css', 'scss', 'image', 'js', 'watch', 'browser-sync']);