-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (57 loc) · 1.78 KB
/
gulpfile.js
File metadata and controls
72 lines (57 loc) · 1.78 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
/**
*
* Gulp file to build the theme
*
*/
// gulp is the main engine
var gulp = require('gulp');
// Gulp Sass to allow us to write SCSS and compile into CSS, based on Node Sass
var sass = require('gulp-sass');
// Lint checks the SCSS we write to ensure it adheres to best practices and standards. Check out link.yml for configuration
var sassLint = require('gulp-sass-lint');
// PostCSS is a cool framework that lets you install other processors that do post-processing on the CSS file
var postcss = require('gulp-postcss');
// autoprefixer is a PostCSS processor that allows us to write standard modern CSS and it will fill in any browser specific stuff
var autoprefixer = require('autoprefixer');
var cleanCSS = require('gulp-clean-css');
/**
* Paths to project folders
*/
var paths = {
styles: {
input: 'scss/**/*.{scss,sass}',
output: 'css/'
},
};
var postCSSProcessors = [
autoprefixer({ browsers: ['last 2 versions'] })
]
gulp.task('lint', ['lint:sass']);
gulp.task('lint:sass', function () {
return gulp.src(paths.styles.input)
// use gulp-cached to check only modified files.
.pipe(sassLint({configFile: 'lint.yml', files: {ignore: 'scss/_variables.scss'}}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
gulp.task('build:styles', function () {
gulp.src(paths.styles.input)
.pipe(sass().on('error', sass.logError))
.pipe(postcss(postCSSProcessors))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest(paths.styles.output))
;
});
/**
* Task Runners
*/
// Compile files
gulp.task('compile', [
'build:styles', 'lint'
]);
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch(['scss/**/*.scss','scss/*.scss'], ['build:styles', 'lint']);
});
// Default Task
gulp.task('default', ['compile']);