forked from GSA/resources.data.gov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
80 lines (69 loc) · 1.92 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
const { src, pipe, dest, series, parallel, watch } = require('gulp');
const uswds = require("@uswds/compile");
var browserify = require('browserify');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify')
var gulpif = require('gulp-if');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
const isProd = process.env.NODE_ENV == 'production';
// file path vars
const paths = {
js: {
src: './pages/_js/index.js',
dest: 'assets/js/bundle.js'
}
}
function jsTask() {
return browserify(`${paths.js.src}`)
.transform('babelify', {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime']
})
.bundle()
.pipe(source(paths.js.dest))
.pipe(buffer())
.pipe(gulpif(isProd, uglify()))
.pipe(gulpif(!isProd, sourcemaps.init({ loadMaps: true })))
.pipe(gulpif(!isProd, sourcemaps.write('.')))
.pipe(dest("_site"));
};
const defaultTask = parallel(
series(
jsTask,
uswds.copyAssets,
uswds.compile,
)
)
/*
***** TODO ********
JS watch task: if we want to recompile JS on change
we'll need to add a JS watch step.
for now, we don't need it...
*/
exports.default = defaultTask
// 3. Compile USWDS
/**
* USWDS version
* Set the major version of USWDS you're using
* (Current options are the numbers 2 or 3)
*/
uswds.settings.version = 3;
/**
* Path settings
* Set as many as you need
*/
uswds.paths.dist.css = './_site/assets/uswds/css';
uswds.paths.dist.js = './_site/assets/uswds/js';
uswds.paths.dist.img = './_site/assets/uswds/img';
uswds.paths.dist.fonts = './_site/assets/uswds/fonts';
uswds.paths.dist.theme = './pages/_scss';
/**
* Exports
* Add as many as you need
*/
exports.init = uswds.init;
exports.compile = uswds.compile;
exports.copyAll = uswds.copyAll;
exports.watch = uswds.watch;
exports.copyAssets = uswds.copyAssets;