Ensure Node version >= 14.16 is installed. Using NVM is recommended.
From the project root, run the following command to install dependencies: ./setup.sh.
Start the application in development mode: yarn start
The frontend application will now be accessible via browser at localhost:8080
If you require the application to run locally over HTTPS, follow the instructions here.
You can disable SSL by setting the DISABLE_SSL env param to true with any start command. (e.g. DISABLE_SSL=true yarn start:staging)
Windows Support
To ensure proper support for Windows, please take the following actions before running the above setup instructions.
Open a Powershell window with rights elevated to an Administrator.
Run npm install -g windows-build-tools. This will install Python 2.7 and Visual C++ Build Tools which are required to compile some native Node modules.
Ensure Python has been added to your environment variables by opening a cmd prompt and typing python. If you get a CommandNotFoundException message, add the folder %USERPROFILE%\.windows-build-tools\python27 to your environment variables.
Tips & Useful Commands
To completely remove all dependencies and artifacts run yarn clean
To add/remove an NPM package run yarn add or yarn remove in the package folder. After installing or uninstalling a NPM package, run yarn in the root folder to re-init the project
All development specific dependencies should be installed as a dev-dependency in the top level package.json via yarn i --save-dev [package-name]
All application specific dependencies should be installed in the specific packages package.json via yarn i --save [package-name]
Running Environments Locally
The frontend application can be ran locally with different build configurations found in config/env. The following commands are available:
yarn start Runs the application with the development.js configuration file
yarn start:dev Runs the application with the development.js configuration file
yarn start:staging Runs the application with the staging.js configuration file
yarn start:prod Runs the application with the production.js configuration file
yarn run:prod Runs the application mimicking the production environment entirely (i.e. code is bundled and minified, HMR is disabled,
Express server is used (./server.js) and the production.js configuration file is loaded)
Notes:
Developers will need to manually create the development.js and staging.js files
Custom application runtimes are possible by modifying the corresponding environment files found in the config/env folder
Note: if you see errors that Jest cannot resolve package imports, you may need to run yarn test before testing specific packages (eg, yarn test:frontend)
Running Tests via Watch
yarn test:watch Watches and then runs desired tests
After running one of the above commands, Node will wait for a debugger to attach before starting the tests.
To attach, simply open your browser and go to chrome://inspect and click on "Open Dedicated DevTools for Node",
which will give you a list of available node instances you can connect to. Click on the address displayed in the terminal
(usually localhost:9229) and you will be able to debug tests using Chrome's DevTools.
Updating Snapshot Tests
We are snapshot testing UI some components. Here are the commands to update them when necessary:
storybook:build-wallet: Builds the static storybook assets for wallet specific components (if base components is running locally, storybook will put wallet and base components into the same storybook UI)
storybook:build-base: Builds the static storybook assets for base shared components
storybook:serve-wallet Builds storybook assets and then serves them locally at localhost:6006
storybook:serve-base Builds storybook assets and then serves them locally at localhost:6007
storybook:deploy-wallet Builds storybook assets and then serves them to github pages. You will probably need to run cd ./packages/blockchain-info-components && git remote add origin [email protected]:blockchain/blockchain-wallet-v4-frontend.git first.
storybook:deploy-base Builds storybook assets and then serves them to github pages. You will probably need to run cd ./packages/blockchain-info-components && git remote add origin [email protected]:blockchain/blockchain-wallet-v4-frontend.git first.
If the deploy begins to fail, deleting the static build file before redeploy will likely help.
请发表评论