This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
72 lines (57 loc) · 1.88 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
'use strict';
// *************************
//
// Run 'gulp' to watch directory for changes for images, fonts icons, Sass, etc.
// Or for full site testing run 'gulp test'
//
// *************************
// Include gulp.
const gulp = require('gulp');
// Include plug-ins.
const atImport = require('postcss-import');
const autoprefixer = require('autoprefixer');
const beeper = require('beeper');
const compass = require('gulp-sass');
const concat = require('gulp-concat');
const cssNano = require('cssnano');
const imagemin = require('gulp-imagemin');
const plumber = require('gulp-plumber');
const postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
// ********************************************************************************************************************************************
// Error Handling to stop file watching from dying on an error (ie: Sass compiling).
var onError = function(err) {
beeper(3);
console.log(err);
};
// Compile the Sass.
gulp.task('styles', function() {
// Sass file to dist.
gulp.src('./sass/**/*').pipe(gulp.dest('./build/dist/sass'));
// Register the PostCSS plugins.
var postcssPlugins = [
atImport,
autoprefixer,
cssNano,
];
// The actual task.
gulp.src('./sass/*.scss')
// Error handling
.pipe(plumber({
errorHandler: onError
}))
// Compile the Sass code.
.pipe(compass({
sass: './sass'
}))
// If there's more than one css file outputted, merge them into one.
// .pipe(concat('./styles.css'))
// Optimise the CSS.
.pipe(postcss(postcssPlugins))
// Output to the css folder.
.pipe(gulp.dest('./build/dist/css/'));
});
// ********************************************************************************************************************************************
// Default gulp task.
gulp.task('default', ['styles']);