This is the front end repository for VA.gov. It contains application code used across the site.
There are several repositories that contain the code and content used to build VA.gov. If you're looking to get started running VA.gov locally, you should read the Getting Started documentation.
Common commands
Once you have the site set up locally, these are some common commands you might find useful:
I want to...
Then you should...
fetch all dependencies
yarn install; run this any time package.json changes
build applications
yarn build
run the webpack dev server
yarn watch
build in codespaces
yarn build:codespaces. Build with codespace options
Building vets-website
Building applications
vets-website uses Webpack to bundle application
assets.
To build all applications, run the following:
yarn build
To build one or more applications, you can use the --entry option:
yarn build --entry=static-pages,auth
To recompile your application when you make changes, run:
yarn watch
You can also limit the applications Webpack builds with --env entry:
yarn watch --env entry=static-pages,auth
The entryname for your application can be found in its manifest.json file.
If you're developing a feature that requires the API, but can't or don't want to
run it locally, you can specify --env api:
yarn watch --env api=https://dev-api.va.gov
You will need to disable CORS in your browser when using a non-local API. Here are some helpful links that explain how to do this:
Note: If you try to log on, ID.me will redirect you to the environment that
the API is set up for. So in the above example, you'd be redirected back to
dev.va.gov.
After building the applications, running yarn build in the ../content-build directory will build content using the generated app bundles from vets-website/build/localhost/generated. The full build can be seen in ../content-build/build/localhost.
If you need to log in, go to your browser dev tools console and enter
localStorage.setItem('hasSession', true) and refresh the page. This will then
trigger a /v0/user call, which will then get the mocked response of a logged-in
user. (Assuming you've mocked that response, of course.)
reset local environment (clean out node modules, Babel cache, and runs npm install)
yarn reset:env
run the app pages on the site for local development
yarn watch --env scaffold
run the site for local development with automatic rebuilding of Javascript and sass with css sourcemaps
yarn watch:css-sourcemaps then visit http://localhost:3001/. You may also set --env buildtype and NODE_ENV though setting NODE_ENV to production will make incremental builds slow.
run the site for local development with automatic rebuilding of code and styles for specific apps
yarn watch --env entry=disability-benefits,static-pages. Valid application names are in each app's manifest.json under entryName
run the site so that devices on your local network can access it
yarn watch --env host=0.0.0.0 --env public=192.168.x.x:3001 Note that we use CORS to limit what hosts can access different APIs, so accessing with a 192.168.x.x address may run into problems
watch file changes without starting the server
yarn watch:no-server
run all unit tests and watch
yarn test:watch
run only E2E tests (headless)
Make sure the site is running locally (yarn watch) and run the tests with yarn cy:run
run E2E tests in the browser
yarn cy:open
count all Cypress E2E specs
yarn cy:count
run all linters
yarn lint
run only javascript linter
yarn lint:js
run only sass linter
yarn lint:sass
run lint on JS and fix anything that changed
yarn lint:js:changed:fix
run visual regression testing
Start the site. Generate your baseline image set using yarn test:visual:baseline. Make your changes. Then run yarn test:visual.
add new npm modules
yarn add my-module. Use the --dev flag for modules that are build or test related.
请发表评论