-
Notifications
You must be signed in to change notification settings - Fork 20
/
gulpfile.js
101 lines (88 loc) · 2.44 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* * * * * ==============================
* * * * * ==============================
* * * * * ==============================
* * * * * ==============================
========================================
========================================
========================================
----------------------------------------
USWDS SASS GULPFILE
----------------------------------------
*/
const autoprefixer = require("autoprefixer");
const csso = require("postcss-csso");
const gulp = require("gulp");
const pkg = require("./node_modules/uswds/package.json");
const postcss = require("gulp-postcss");
const replace = require("gulp-replace");
const sass = require("gulp-sass");
const sourcemaps = require("gulp-sourcemaps");
const uswds = require("./node_modules/uswds-gulp/config/uswds");
const concat = require('gulp-concat');
sass.compiler = require("sass");
/*
----------------------------------------
PATHS
----------------------------------------
- All paths are relative to the
project root
- Don't use a trailing `/` for path
names
----------------------------------------
*/
// Project Sass source directory
const PROJECT_SASS_SRC = "./libs/sass";
// Compiled CSS destination
const CSS_DEST = "./libs/css";
// font destination
const FONT_DEST = "./libs/css/fonts";
/*
----------------------------------------
TASKS
----------------------------------------
*/
gulp.task("icons", () => {
return gulp.src('node_modules/@fortawesome/fontawesome-free/webfonts/*')
.pipe(gulp.dest(`${FONT_DEST}/fontawesome`));
});
gulp.task("build-sass", function(done) {
var plugins = [
// Autoprefix
autoprefixer({
cascade: false,
grid: true
}),
// Minify
csso({ forceMediaMerge: false })
];
return (
gulp
.src([`${PROJECT_SASS_SRC}/styles.scss`])
.pipe(sourcemaps.init({ largeFile: true }))
.pipe(
sass.sync({
includePaths: [
`${PROJECT_SASS_SRC}`,
`${uswds}/scss`,
]
})
)
.pipe(postcss(plugins))
.pipe(sourcemaps.write("."))
.pipe(concat('leaf.css')) // added to make all files roll into one big CSS
.pipe(gulp.dest(`${CSS_DEST}`))
);
});
gulp.task(
"init",
gulp.series(
"icons",
"build-sass",
)
);
gulp.task("watch-sass", function() {
gulp.watch(`${PROJECT_SASS_SRC}/**/*.scss`, gulp.series("build-sass"));
});
gulp.task("watch", gulp.series("build-sass", "watch-sass"));
gulp.task("default", gulp.series("watch"));