Setting up your local frontend environment
A step-by-step guide to setting up the VA.gov frontend environment locally.
Step 1: Set up Node
Install
nvm:Please follow instructions in the nvm documentation for installing this dependency.
Install
node 14.15.0(this also installsnpm):BASHnvm install 14.15.0Configure
nvmto usenode 14.15.0by default:BASHnvm alias default 14.15.0Install
yarn 1.19.1globally:BASHnpm i -g yarn@1.19.1Verify correct versions of
nodeandyarnare installed:BASHnode --version # 14.15.0 yarn --version # 1.19.1
Step 2: Get the source code
Clone VA.gov git repos as sibling directories:
git clone git@github.com:department-of-veterans-affairs/vets-website.git
git clone git@github.com:department-of-veterans-affairs/vagov-content.git
git clone git@github.com:department-of-veterans-affairs/content-build.git
git clone git@github.com:department-of-veterans-affairs/vets-json-schema.git
git clone git@github.com:department-of-veterans-affairs/veteran-facing-services-tools.git
git clone git@github.com:department-of-veterans-affairs/vets-api.git
git clone git@github.com:department-of-veterans-affairs/vets-api-mockdata.git
Front end repos
vets-website: Core front end platform and application codevagov-content: Markdown content used to generate static pagescontent-build: Liquid templates and content build for static pagesveteran-facing-services-tools: Shared front end components (including non VA.gov users) and front end documentation site
Back end repos
vets-api: Core Rails API server application codevets-api-mockdata: Mock data used when running locally and on dev for the backend
Shared repos
vets-json-schema: Shared JSON Schema definitions used by form applications and the APIs that they consume
Step 3: Start up the front end
vets-website
Navigate to the
vets-websiterepository, then installvets-websitedependencies. See these common commands for more information.BASHcd vets-website yarn installBuild all applications for
vets-website. Run this standard build script if you need all the CSS and JS generated for work incontent-build.BASHyarn buildIf you are only working in an Isolated application(s) (or do not need to build all applications), you can build one or more application(s) with the
--entryoption.BASHyarn build --entry=static-pages,authTo get Intellisense in your IDE (autocomplete + cmd/ctrl-clicking on files) to work reliably, copy
jsconfig-example.jsontojsconfig.jsonand make adjustments in that file according to your project.Start the local development server for all applications. If you are applying CSS and/or JS changes to a static page/template that renders in
content-build, we recommend leaving this command running so you will be able to see the changes incontent-build.BASHyarn watchAgain, you can limit the watch to one or more application(s) with the
--entryoption.BASHyarn watch --env entry=static-pages,auth
The watch is complete when the CLI saysCompiled successfully.
If you would like webpack to open a browser window for you, please runyarn watch --open. We use Webpack DevServer to watch and serve the files locally; all the same options and documentation should apply.Open http://localhost:3001 in a browser if you are working on an app; otherwise, continue on to the content-build section for viewing changes in the browser.
You can learn more about building applications in the vets-website GitHub readme.
content-build
In order to run content-build, you must first generate the CSS and JS files within vets-website (follow steps above). If you don't, you will see a build error in the console instructing you to first generate files in vets-website. If you are applying CSS and/or JS changes to a static page/template that renders in content-build (like the homepage) you will need to run a watch in vet-website to view the updates. The CSS and JS files within vets-website are locally connected through a symlink in the build process.
If you don't need to locally view static pages and are just working on applications, you don't need to set this part up.
Navigate to the
content-buildrepository, then install dependencies viayarn.BASHcd content-build yarn installContent-build steps requires an additional set up step due to code changes in the app. If building content from Drupal, it requires a one-time setup of a
.envfile to supply connection information.BASHcp .env.example .envBuild
content-build. Make sure you configured the SOCKS proxy to fetch content from Drupal. For a faster installation, use step 4 first.BASHyarn buildIf you do not have access to the SOCKS proxy, you can alternately fetch the latest cached version of the content.
BASHyarn fetch-drupal-cacheStart the local development server.
BASHyarn watchThe watch is complete when the CLI says
Compiled successfully. If you just need a server running without watching the metalsmith files you can runnpx http-server . -p 3002inside/build/localhostto save some CPU.Open http://localhost:3002 in a browser.
Step 4: Backend and internal tools set up
Full backend support
Setting up the backend and internal tools allows local test account login and static content rendering.
Backend (
vets-api) set up instructions.The local
vets-websiteis configured to point to thevets-apibackend athttp://localhost:3000. Any website functionality that depends on the backend (i.e. login, save-in-progress, form submission, feature toggles) will require a locally running instance ofvets-api.To log in with a test account locally, see instructions for how to access VA.gov in Staging
Internal tools setup instructions
This proxy setup is required to access static content locally and to access to our reporting and monitoring tools. Running the
yarn watchtask with the SOCKS proxy active will automatically pull and cache the static content forvets-website.
Mock API setup
Running a mock API for local development: This option will mock specific backend endpoints, but it is not comprehensive. You can modify the file to mock specific endpoints and supply the data that you need to test locally.
Troubleshooting
content-build
[Error: ENOENT: no such file or directory, open '{file path on your local machine}']
The vagov-content repository sits adjacent to
content-buildin the same way thatvets-websitedoes. The markdown files invagov-contentare pulled in during the build process. If a markdown file is present invagov-content, but the template was deleted incontent-build, you'll see a build error that reads something like this.Steps to Resolve.
If this happens to you, make sure you have the latest from the
vagov-contenton your local machine, and try buildingcontent-buildagain.
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.