Skip to content

Commit af4abd1

Browse files
wpyogafrenck
andauthored
Clarify frontend development documentation (#2497)
Co-authored-by: Franck Nijhof <[email protected]>
1 parent 2d96523 commit af4abd1

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

docs/frontend/development.md

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,55 @@ git remote add upstream https://github.com/home-assistant/frontend.git
2525

2626
You will need to have an instance of Home Assistant set up. See our guide on [setting up a development environment](/development_environment.mdx).
2727

28-
Next step is to configure Home Assistant to use the development mode for the frontend. Do this by updating the frontend config in your `configuration.yaml` and set the path to the frontend repository that you cloned in the last step:
28+
#### Developing with Visual Studio Code + dev container
2929

30-
```yaml
31-
frontend:
32-
# Example absolute path: /home/paulus/dev/hass/frontend
33-
development_repo: /path/to/hass/frontend/
34-
```
35-
36-
If you are using Visual Studio Code with devcontainers for Home Assistant, you need to mount the `frontend` directory into the container. Add the following section to `.devcontainer/devcontainer.json`:
30+
If you are using Visual Studio Code with dev containers for Home Assistant Core, you need to mount the frontend repository into the dev container. Add the following section to `.devcontainer/devcontainer.json` in the Home Assistant Core repository:
3731

3832
```json
3933
"mounts": [
4034
"source=/path/to/hass/frontend,target=/workspaces/frontend,type=bind,consistency=cached"
4135
]
4236
```
4337

44-
The Home Assistant's devcontainer needs to get rebuilt via the `Dev Containers: Rebuild Container` with: Shift+Command+P(Mac) / Ctrl+Shift+P (Windows/Linux). The `configuration.yaml` should point to the path inside the container:
38+
Rebuild the dev container by pressing Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux) to open the Command Palette, then selecting the **Dev Containers: Rebuild Container** command.
39+
40+
Edit `config/configuration.yaml` at the root of the Home Assistant Core repository to add this entry:
4541

4642
```yaml
4743
frontend:
48-
development_repo: /workspaces/frontend/
44+
development_repo: /workspaces/frontend
4945
```
5046
47+
:::note
48+
This is the mounted path inside the dev container, see the `target` parameter above. If the `source` path is incorrect, the web frontend won't work.
49+
:::
50+
51+
Run Home Assistant Core from VS Code:
52+
1. Open the Command Palette:
53+
- Mac: `Shift+Command+P`
54+
- Windows/Linux: `Ctrl+Shift+P`
55+
2. Select **Tasks: Run Task**
56+
3. Select **Run Home Assistant Core**
57+
5158
:::caution
52-
The change to `.devcontainer/devcontainer.json` should be excluded from any PR as it contains your local path to the `frontend` repository. Since the the settings in `.devcontainer/devcontainer.json` are only processed during the container rebuild, you can safely roll back the change after the rebuild has completed.
59+
The change to `.devcontainer/devcontainer.json` should be excluded from any PR as it contains your local path to the `frontend` repository. Since the settings in `.devcontainer/devcontainer.json` are only processed during the container rebuild, you can safely roll back the change after the rebuild has completed.
60+
:::
61+
62+
#### Developing with a manual environment
63+
64+
If you set up the development environment for Home Assistant Core manually, fill in the frontend repository path in `configuration.yaml`:
65+
66+
```yaml
67+
frontend:
68+
# Example path: /home/paulus/dev/hass/frontend
69+
development_repo: /path/to/hass/frontend
70+
```
71+
72+
:::tip
73+
The `configuration.yaml` file can be found in the `config` directory at the root of the Home Assistant Core repository. If the path is incorrect or otherwise inaccessible, the web frontend won't work.
5374
:::
5475

55-
### Installing Node.js
76+
### Installing Node.js (manual environment only)
5677

5778
Node.js is required to build the frontend. The preferred method of installing node.js is with [nvm](https://github.com/nvm-sh/nvm). Install nvm using the instructions in the [README](https://github.com/nvm-sh/nvm#install--update-script), and install the correct node.js by running the following command:
5879

@@ -62,36 +83,48 @@ nvm install
6283

6384
[Yarn](https://yarnpkg.com/en/) is used as the package manager for node modules. [Install yarn using the instructions here.](https://yarnpkg.com/getting-started/install)
6485

65-
Next, development dependencies need to be installed to bootstrap the frontend development environment. First activate the right Node version and then download all the dependencies:
86+
### Install development dependencies and fetch latest translations
87+
88+
Bootstrap the frontend development environment by installing development dependencies and downloading the latest translations.
6689

6790
```shell
6891
nvm use
6992
script/bootstrap
7093
script/setup_translations
7194
```
7295

96+
:::note
97+
This needs to be done manually, even if you are using dev containers. Also, you will be asked to enter a code and authorize the script to fetch the latest translations.
98+
:::
99+
73100
## Development
74101

75-
During development, you will need to run the development script to maintain a development build of the frontend that auto updates when you change any of the source files. To run this server, run:
102+
### Run development server
103+
104+
Run this script to build the frontend and run a development server:
76105

77106
```shell
78107
nvm use
79108
script/develop
80109
```
81110

82-
Make sure you have cache disabled and correct settings to avoid stale content:
111+
When the script has completed building the frontend, and Home Assistant Core has been set up correctly, the frontend will be accessible at `http://localhost:8123`. The server will automatically rebuild the frontend when you make changes to the source files.
112+
113+
### Browser settings
114+
115+
Open Google Chrome's Developer tools, and make sure you have cache disabled and correct settings to avoid stale content:
83116

84117
:::info
85118
Instructions are for Google Chrome
86119
:::
87120

88-
1. Disable cache by ticking the box in `Network` > `Disable cache`
121+
1. Disable cache by ticking the box in **Network** > **Disable cache**
89122

90123
<p class='img'>
91124
<img src='/img/en/development/disable-cache.png' />
92125
</p>
93126

94-
2. Enable Bypass for network in `Application` > `Service Workers` > `Bypass for network`
127+
2. Enable Bypass for network in **Application** > **Service Workers** > **Bypass for network**
95128

96129
<p class='img'>
97130
<img src='/img/en/development/bypass-for-network.png' />

0 commit comments

Comments
 (0)