forked from markconroy/contact.ie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (76 loc) · 2.59 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
var gulp = require('gulp-help')(require('gulp'));
sourcemaps = require('gulp-sourcemaps'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
cleancss = require('gulp-clean-css'),
notify = require('gulp-notify'),
spritesmith = require('gulp.spritesmith'),
browserSync = require('browser-sync').create();
sassGlob = require('gulp-sass-bulk-import');
csscomb = require('gulp-csscomb');
sassLint = require('gulp-sass-lint');
// Error notifications.
var reportError = function (error) {
notify({
title: 'Gulp Task Error',
message: 'Check the console.'
}).write(error);
// print the error in terminal.
console.log(error.toString());
this.emit('end');
};
gulp.task('styles', 'Creates production-ready css', function() {
return gulp.src('./sass/**/*.scss')
.pipe(sassGlob())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({browsers: ['last 2 versions', 'ie 9']}))
.pipe(gulp.dest('css'));
});
gulp.task('styles:dev', 'Creates developer-friendly css', function() {
return gulp.src('sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sassGlob())
.pipe(sass().on('error', reportError))
.pipe(autoprefixer({browsers: ['last 2 versions', 'ie 9']}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
gulp.task('lint', false, function() {
return gulp.src('sass/**/*.s+(a|c)ss')
.pipe(sassLint({
options: {
formatter: 'table'
},
configFile: '.sass-lint.yml'
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError());
})
gulp.task('comb', false, function() {
return gulp.src(['sass/**/*.scss'], {base: './'})
.pipe(csscomb())
.pipe(gulp.dest('./'));
})
gulp.task('sprite', false, function () {
var spriteData = gulp.src('images/sprites/*.png')
.pipe(spritesmith({
/* this whole image path is used in css background declarations */
imgName: '../images/sprites/sprite/sprite.png',
cssName: '_sprites.scss'
}));
spriteData.img.pipe(gulp.dest('img'));
spriteData.css.pipe(gulp.dest('sass'));
});
gulp.task('watch', 'Watches for your changes and refreshes all teh things', function() {
var config = require('./gulpfile-config.json');
// Set your localhost address
browserSync.init({
proxy: config.browserSync.proxy
});
// Watch .scss files
gulp.watch(['images/sprites/*.png'], ['sprite']);
gulp.watch(["sass/**/*.scss", "sprites.scss", 'images/**/*'], ['styles:dev']);
gulp.watch(['css/style.css', 'js/**/*.js', '.php']).on('change', browserSync.reload);
});
gulp.task("default", ["help"]);