-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (70 loc) · 1.68 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
/*
* NPM Packages
*/
const gulp = require('gulp'),
autoprefixer = require('autoprefixer'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload,
mqpacker = require('css-mqpacker'),
cssnano = require('cssnano'),
pump = require('pump')
environments = require('gulp-environments'),
notify = require('gulp-notify'),
postcss = require('gulp-postcss'),
sass = require('gulp-sass');
sass.compiler = require('node-sass');
/*
* Variables
*/
const paths = {
styles: {
scss: './scss/',
css: './css/'
}
},
sassPrecision = 10,
development = environments.development,
production = environments.production;
/*
* Tasks
*/
// Scss
function scss(cb) {
let pluginsProd = [
autoprefixer(),
mqpacker(),
cssnano()
],
pluginsDev = [
autoprefixer(),
mqpacker()
];
pump(
[
gulp.src(paths.styles.scss + '**/*.scss'),
sass({
precision: sassPrecision,
sourceComments: production() ? false : true,
outputStyle: 'nested'
}).on('error', sass.logError),
postcss(production() ? pluginsProd : pluginsDev),
gulp.dest(paths.styles.css),
development(browserSync.stream()),
development(notify({ message: 'Scss task complete' }))
],
cb
);
}// END css
// Watch
function watch() {
// Watch SCSS
gulp.watch(paths.styles.scss + '**/*.scss', scss);
}
/**
* Tasks
*/
// Export tasks
exports.watch = watch;
exports.scss = scss;
exports.default = gulp.series(scss, watch);
exports.build = scss;