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.jsA
vendor.jsfile 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.jsGenerated by Webpack's SplitChunksPlugin
Includes shared dependencies such as
react,redux, andnode_modules
web-components.entry.jsVA.gov Design System's
npmmodule: https://github.com/department-of-veterans-affairs/component-libraryGenerated by Webpack code splitting with a dynamic
importinsrc/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
/configCypress End-to-End configurations:
cypress-reporters.jsoncypress-testrail.jsoncypress.json
Nightwatch.jsEnd-to-End test runner and configurations:nightwatch-globals-sauce.jsnightwatch-sauce.jsnightwatch.docker-compose.jsnightwatch.js
Sass configuration:
sass-lint.ymlWebpack production and development configurations:
webpack.config.jswebpack.dev.config.js
/docs: Best practices and troubleshooting documents/jenkins: Jenkins setup, build, and deploy scripts for thevets-websiterepository/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-websitebuild-help.js: Used in thewatch.jsscript for outputting CLI optionsbuild.sh: Buildsvets-websiteapplicationscan-i-deploy.js: Used for verifying if changes can be deployed in Pact Broker contract testscheck-node-version.js: Checks if the necessarynodeversion 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 agitbranch based off ofmainprebuild.js:npmpre-build script that checks thenodeversion and installs pre-commit hookspublish-pacts.js: Publishes and tagspactsgenerated by Pact Broker testsreset-environment.js: Installsyarnand removes Babel cache andnode_modulesdirectoryreview-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-apiin 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.jsscriptrun-unit-test.js: Runs unit testssecurity-check.js: Checks for security advisories in dependenciesupdate-json-schema.sh: Helper for updating dependency version ofvets-json-schemautils.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-websiteapplications/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.