The repository should provide a collection of ready-to-use Lightning Web Components that might help your SFDX project and is intended to grow over time. Additionally, it also includes an initial configuration of Prettier, linting rules, git hooks and unit tests as well as useful VS Code settings. The setup really focuses on LWC development.
To use this library and try out the components locally, Node and the Salesforce CLI should already be installed.
To get the components up and runnning, you need to open the repository with VS Code, install all the recommended extensions and run npm install
to install all required dependencies.
You need to authorize an org before you use the local development server. This is necessary because all data requests using Lightning Data Service or Apex will get proxied to the Salesforce org and returned in the local components. In VS Code the authorization can be done by pressing Command + Shift + P, enter "sfdx", and select SFDX: Authorize an Org.
Alternatively you can also run the following command from the command line:
sfdx force:auth:web:login
Lightning Web Components can be viewed and developed locally without the need to push them to an org first. To set up local development you only nedd to install the development server after you authorized an org.
The local development server and its configuration are provided by a Salesforce CLI plugin that can be installed as follows:
sfdx plugins:install @salesforce/lwc-dev-server
Run npm run server:lwc
to start the server on http://localhost:3333 and access all components of this project.
The following list of components is part of this repo. All components contain corresponding unit tests and docs.
- CSV To Datatable
- Custom Datatable
- Custom Slider
- Hello World
- iFrame
- Local Development Wrapper
- Multi Select Combobox
You can also find many more useful and reusable Lightning Web Components in the official lwc-recipes.
The project includes client-side pre-commit git hooks using husky and lint-staged. After installing all project dependencies, Prettier, Linter and unit tests are automatically executed before each commit.
Run npm run prettier
to check all files for Prettier issues.
Run npm run lint
to check for ESLint issues.
Run
npm run test:unit
to execute all unit tests only oncenpm run test:unit:watch
to execute all unit tests in watch mode for developmentnpm run test:unit:coverage
to execute all unit tests with generated code coverage
Run npm run docs
to generate code documentation with JSDoc in HTML format.