-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (60 loc) · 2.17 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
//*********** Gulp file for v4
//*********** Gulp variables & plugins
const gulp = require('gulp'),
autoprefixer = require('autoprefixer'), //in case it helps postcss-preset-env
cssbrief = require('gulp-shorthand'), //shorthands css code where possible
del = require('del'), //removes files and folders
log = require('fancy-log'), //log output like gulp's
plumber = require('gulp-plumber'),
postcss = require('gulp-postcss'), //needed for polyfills
postcsspart = require('postcss-partial-import'),
postcsspre = require('postcss-preset-env'), //polyfills the snot out of the code
uglifycss = require('gulp-uglifycss'); //squash css code so it isn't human readable
webserver = require('gulp-webserver');
//*********** Gulp individual tasks
// Removes processed files to be re-written
gulp.task('pre-build', function(done) {
del('./docs/s/ds.css').then(paths => {
log('Deleted:', paths.join('\n'));
done();
});
});
// CSS processing, add prefixes, & minify
gulp.task('css', function() {
return gulp.src('./src/local/ds.css')
.pipe(plumber())
.pipe(postcss([postcsspart()]))
.pipe(cssbrief())
.pipe(uglifycss())
.pipe(gulp.dest('./docs/s/'));
});
gulp.task('postcss', function() {
return gulp.src('./docs/s/ds.css')
.pipe(postcss([
postcsspre({
importFrom: './src/css/root.css',
browsers: '> 0.1%',
autoprefixer: {
grid: true,
browsers: ['> 0.1%']
}
})
]))
.pipe(gulp.dest('./docs/s/'));
});
// Local development via `gulp webserver`
gulp.task('webserver', function() {
gulp.src('./docs')
.pipe(webserver({
// GULP_LIVERELOAD env var set false to turn off, or true (default)
livereload: (typeof process.env.GULP_LIVERELOAD == 'undefined' || String(process.env.GULP_LIVERELOAD).toLowerCase() === 'true'),
directoryListing: false,
open: '/design-system',
liveReload: true,
path: '/design-system',
port: process.env.GULP_PORT || '8000'
}));
});
//*********** Primary tasks
gulp.task('default', gulp.series('pre-build', 'css', 'postcss'));
//*********** EOF