diff --git a/postcss.config.js b/postcss.config.js index e267960..db3ec88 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -4,7 +4,7 @@ module.exports = { ...(process.env.NODE_ENV === "production" ? [ require("@fullhuman/postcss-purgecss")({ - content: ["./.11ty-vite/**/*.html"], + content: ["./.11ty-vite/**/*.html", "./.11ty-vite/**/*.js"], safelist: ["usa-js-loading"], extractors: [ { diff --git a/src/js/index.js b/src/js/index.js index 6dbdc11..c274d1b 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1,5 +1,12 @@ import "@uswds/uswds/css/uswds.min.css" import { accordion, banner, navigation } from "@uswds/uswds/js" + +// This is part of the "uswds-init" machinery to handle failure to load JS +// gracefully. Normally uswds-core/src/js/start.js would do this for us, but +// this file only gets included in bundles - there's no way to individually +// include it. +window.uswdsPresent = true + accordion.on() banner.on() navigation.on()