Bundles and Code Organization
Application Bundling with Webpack
Webpack is a modular asset bundler used to build VA.gov client applications. Its responsibilities include:
Dependency resolution in JavaScript and CSS files
Splitting the project into application specific and shared resources during the build process
Enabling support for legacy web browsers
Performance optimization
Providing the application launch behavior that ties all of this together
Our Webpack configuration leverages the CommonsChunkPlugin to code split source code into:
Entry files that are application specific e.g.
facilities-locator.entry.js
A
vendor.js
file containing common modules shared between entry points
Webpages load application specific files on demand. More information on this can be found in Webpack’s code splitting documentation.
Common bundles
Common entry files included on every page:
vendor.entry.js
Generated by Webpack's SplitChunksPlugin
Includes shared dependencies such as
react
,redux
, andnode_modules
web-components.entry.js
VA.gov Design System's
npm
module: https://github.com/department-of-veterans-affairs/component-libraryGenerated by Webpack code splitting with a dynamic
import
insrc/platform/site-wide/wc-loader.js
Examples of application entry files:
static-pages.entry.js
: Included on all non-React pages, e.g. https://www.va.govgi.entry.js
: Stand alone React app, e.g. https://www.va.gov/gi-bill-comparison-toolpre-need.entry.js
: React app that uses the VA.gov Forms Library, e.g. https://www.va.gov/burials-and-memorials/pre-need/form-10007-apply-for-eligibility/introduction
Directory Structure of vets-website
/config
Cypress End-to-End configurations:
cypress-reporters.json
cypress-testrail.json
cypress.json
Nightwatch.js
End-to-End test runner and configurations:nightwatch-globals-sauce.js
nightwatch-sauce.js
nightwatch.docker-compose.js
nightwatch.js
Sass configuration:
sass-lint.yml
Webpack production and development configurations:
webpack.config.js
webpack.dev.config.js
/docs
: Best practices and troubleshooting documents/jenkins
: Jenkins setup, build, and deploy scripts for thevets-website
repository/script
/component-migration
: Scripts for migrating React components toweb components
/eslint-plugin-va
: Project specific linting plugin/github-actions
: Scripts used in GitHub Actions workflowsapp-coverage-report.js
: Generates coverage report for all applications in the repositoryapp-list.sh
: Outputs a list of the applications invets-website
build-help.js
: Used in thewatch.js
script for outputting CLI optionsbuild.sh
: Buildsvets-website
applicationscan-i-deploy.js
: Used for verifying if changes can be deployed in Pact Broker contract testscheck-node-version.js
: Checks if the necessarynode
version is installedinstall-repos.sh
: Clones sibling repositories needed for running the entire site locallymocha.js
: Unit test runner and watch taskpr-check.js
: Used in CI to determine if platform-release-tools should be requested in a PRpre-push.sh
: Checks if new commits have been added to agit
branch based off ofmain
prebuild.js
:npm
pre-build script that checks thenode
version and installs pre-commit hookspublish-pacts.js
: Publishes and tagspacts
generated by Pact Broker testsreset-environment.js
: Installsyarn
and removes Babel cache andnode_modules
directoryreview-entrypoint.sh
: Builds and serves the site in review instance setuprun-cypress-tests-docker.js
: Used for running Cypress tests in a Docker containerrun-docker-nightwatch.sh
: Runs mockvets-api
in a Docker containerrun-mockapi.sh
: Runs mock API serverrun-nightwatch.sh
: Test harness for running Nightwatch.js testsrun-review-instance-api.js
: Runs a local build that points to a review instance APIrun-unit-test-help.js
: Outputs CLI options forrun-unit-test.js
scriptrun-unit-test.js
: Runs unit testssecurity-check.js
: Checks for security advisories in dependenciesupdate-json-schema.sh
: Helper for updating dependency version ofvets-json-schema
utils.js
: Utility functions used throughout the repositorywatch-tests.js
: Watch task for unit tests (proof of concept)watch.js
: Starts the Webpack dev server
/src
: Source files forvets-website
applications/applications
: Application specific code that gets bundled in Webpack/platform
: Shared code that includes polyfills, code thats injected directly into the site, or used for testing/site
: Contains assets used in applications, and constants used throughout the repository
Runtime configs used locally and in CI for builders, dependency managers, linters, transcoders, and source control
json-config-example.json
: IntelliSense configuration for supporting babel-plugin-module-resolver
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.