-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into crysacarter-patch-2
- Loading branch information
Showing
42 changed files
with
6,956 additions
and
16,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20 | ||
20.14.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ github: | |
default_branch: main | ||
|
||
scripts: | ||
- assets/uswds/js/uswds.min.js | ||
- assets/js/bundle.js | ||
|
||
styles: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,80 @@ | ||
var autoprefixer = require('autoprefixer'); | ||
const csso = require('postcss-csso'); | ||
var gulp = require('gulp'); | ||
var mqpacker = require('css-mqpacker'); | ||
var path = require('path'); | ||
var pkg = require('./node_modules/uswds/package.json'); | ||
var postcss = require('gulp-postcss'); | ||
var rename = require('gulp-rename'); | ||
var replace = require('gulp-replace'); | ||
var sass = require('gulp-dart-sass'); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
var uswds = require('./node_modules/uswds-gulp/config/uswds'); | ||
const { src, pipe, dest, series, parallel, watch } = require('gulp'); | ||
const uswds = require("@uswds/compile"); | ||
|
||
var watchify = require('watchify'); | ||
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'); | ||
var log = require('gulplog'); | ||
var assign = require('lodash.assign'); | ||
|
||
// Project Javascript source directory | ||
const PROJECT_JS_SRC = './pages/_js'; | ||
|
||
// Javascript destination | ||
const PROJECT_JS_DEST = './_site/assets/js'; | ||
|
||
// Project Sass source directory | ||
const PROJECT_SASS_SRC = './pages/_scss'; | ||
|
||
// Images destination | ||
const IMG_DEST = './_site/assets/uswds/img'; | ||
|
||
// Fonts destination | ||
const FONTS_DEST = './_site/assets/uswds/fonts'; | ||
|
||
// Javascript destination | ||
const JS_DEST = './_site/assets/uswds/js'; | ||
|
||
// Compiled CSS destination | ||
const CSS_DEST = './_site/assets/uswds/css'; | ||
|
||
/* | ||
---------------------------------------- | ||
TASKS | ||
---------------------------------------- | ||
*/ | ||
|
||
gulp.task('copy-uswds-fonts', () => { | ||
return gulp.src(`${uswds}/fonts/**/**`).pipe(gulp.dest(`${FONTS_DEST}`)); | ||
}); | ||
|
||
gulp.task('copy-uswds-images', () => { | ||
return gulp.src(`${uswds}/img/**/**`).pipe(gulp.dest(`${IMG_DEST}`)); | ||
}); | ||
|
||
gulp.task('copy-uswds-js', () => { | ||
return gulp.src(`${uswds}/js/**/**`).pipe(gulp.dest(`${JS_DEST}`)); | ||
}); | ||
|
||
gulp.task('build-sass', function (done) { | ||
var plugins = [ | ||
autoprefixer({ | ||
cascade: false, | ||
grid: true, | ||
}), | ||
csso({ forceMediaMerge: false }), | ||
]; | ||
return gulp | ||
.src(`${PROJECT_SASS_SRC}/styles.scss`) | ||
.pipe(sourcemaps.init({ largeFile: true })) | ||
.pipe( | ||
sass({ | ||
includePaths: [PROJECT_SASS_SRC, `${uswds}/scss`, `${uswds}/scss/packages`], | ||
}) | ||
) | ||
.pipe(replace(/\buswds @version\b/g, 'based on uswds v' + pkg.version)) | ||
.pipe(postcss(plugins)) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest(CSS_DEST)); | ||
}); | ||
|
||
var customOpts = { | ||
entries: [`${PROJECT_JS_SRC}/index.js`], | ||
}; | ||
var opts = assign({}, watchify.args, customOpts); | ||
var b = function () { | ||
return browserify(opts); | ||
}; | ||
var w = watchify(b()); | ||
|
||
var bundle = function (pkg) { | ||
return pkg | ||
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() | ||
.on('error', log.error.bind(log, 'Browserify Error')) | ||
.pipe(source('bundle.js')) | ||
.pipe(source(paths.js.dest)) | ||
.pipe(buffer()) | ||
.pipe(sourcemaps.init({ loadMaps: true })) | ||
.pipe(sourcemaps.write('./')) | ||
.pipe(gulp.dest(PROJECT_JS_DEST)); | ||
.pipe(gulpif(isProd, uglify())) | ||
.pipe(gulpif(!isProd, sourcemaps.init({ loadMaps: true }))) | ||
.pipe(gulpif(!isProd, sourcemaps.write('.'))) | ||
.pipe(dest("_site")); | ||
}; | ||
|
||
gulp.task('build-js', bundle.bind(null, b())); | ||
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 | ||
|
||
gulp.task('default', gulp.series('copy-uswds-fonts', 'copy-uswds-images', 'copy-uswds-js', 'build-js', 'build-sass')); | ||
// 3. Compile USWDS | ||
|
||
gulp.task('watch-js', function () { | ||
bundle(w); | ||
w.on('update', bundle.bind(null, w)); | ||
w.on('log', log.info); | ||
}); | ||
/** | ||
* USWDS version | ||
* Set the major version of USWDS you're using | ||
* (Current options are the numbers 2 or 3) | ||
*/ | ||
uswds.settings.version = 3; | ||
|
||
gulp.task('watch-sass', function () { | ||
gulp.watch(`${PROJECT_SASS_SRC}/**/*.scss`, gulp.series('build-sass')); | ||
}); | ||
/** | ||
* 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; |
Oops, something went wrong.