Run a recipe in your local environment by following these steps.
This project uses Volta to ensure that all the contributors share the same version of Node and Yarn for development. Even if you aren't contributing to this project and are running and configuring recipes for your own use only, we recommend installing Volta before you install Node and Yarn.
We use Yarn because it is significantly faster than npm for our use case. See this command cheatsheet.
git clone git@github.com:salesforce/lwr-recipes.git
cd lwr-recipesyarn installIf this command fails with an error about UNABLE_TO_GET_ISSUER_CERT_LOCALLY, Error: unable to get local issuer certificate, or a registry communication issue then verify that the yarn installation was successful.
yarn buildNavigate to your chosen recipe and run the recipe. Using hello-world for example:
cd packages/hello-world
yarn startOpen the site at http://localhost:3000
Recipes can be started in four different modes:
| Mode | Start Command | Format | File Watch | Bundling | Minify |
|---|---|---|---|---|---|
| dev | yarn dev |
ESM | ✅ | 🚫 | 🚫 |
| prod | yarn start |
ESM | 🚫 | ✅ | ✅ |
| compat | yarn start:compat |
AMD | ✅ | 🚫 | 🚫 |
| prod-compat | yarn start:prod-compat |
AMD | 🚫 | ✅ | ✅ |
Running a recipe in dev mode uses hot reloading for easier debugging, so when you change a component in one place it updates immediately. In dev mode, the server registers all file paths and watches them individually.
Cleaning a recipe removes the build directory and file cache. This command is useful if you run into errors or have a stale project.
yarn clean