You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy the initial section on setting up a development environment from the Core repository developer documentation.
Explicitly separate the instructions for doing a manual setup from a devcontainer setup.
Move the preferred devcontainer instructions to the top .
Added some clarifications and cleanup to the other sections.
The Home Assistant frontend is built using web components. For more background about our technology choices, [see this blog post](https://developers.home-assistant.io/blog/2019/05/22/internet-of-things-and-the-modern-web.html).
7
20
8
21
:::caution
9
22
Do not use development mode in production. Home Assistant uses aggressive caching to improve the mobile experience. This is disabled during development so that you do not have to restart the server in between changes.
10
23
:::
11
24
12
-
## Setting up the environment
25
+
## Setup with Visual Studio Code + devcontainer
13
26
14
-
### Getting the code
27
+
The easiest way to get started with development is to use Visual Studio Code with devcontainers. This approach will create a preconfigured development environment with all the tools you need. This approach is enabled for all Home Assistant repositories. [Learn more about devcontainers.](https://code.visualstudio.com/docs/remote/containers)
15
28
16
-
The first step is to fork the [frontend repository][hass-frontend] and add the upstream remote. You can place the forked repository anywhere on your system.
-[Visual Studio code](https://code.visualstudio.com/)
33
+
-[Git](https://git-scm.com/)
23
34
24
-
### Configuring Home Assistant
35
+
**Getting started:**
25
36
26
-
You will need to have an instance of Home Assistant set up. See our guide on [setting up a development environment](/development_environment.mdx).
37
+
1. Go to [Home Assistant frontend repository][hass-frontend] and click "fork".
38
+
2. Once your fork is created, copy the URL of your fork and paste it below, then click "Open":
39
+
<RepositoryOpener />
40
+
3. Your browser will prompt you if you want to use Visual Studio Code to open the link, click "Open Link".
41
+
4. When Visual Studio Code asks if you want to install the Remote extension, click "Install".
42
+
5. The Dev Container image will then be built (this may take a few minutes), after this your development environment will be ready.
27
43
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:
44
+
In the future, if you want to get back to your development environment: open Visual Studio Code, click on the "Remote Explorer" button in the sidebar, select "Containers" at the top of the sidebar.
29
45
30
-
```yaml
31
-
frontend:
32
-
# Example absolute path: /home/paulus/dev/hass/frontend
33
-
development_repo: /path/to/hass/frontend/
34
-
```
46
+
**Configuring Home Assistant**
35
47
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`:
48
+
1. Follow the [instructions for setting up a Home Assistant devcontainer](https://developers.home-assistant.io/docs/development_environment#developing-with-visual-studio-code--devcontainer)
49
+
2. Mount the `frontend` directory into the Core devcontainer by adding the following section to `.devcontainer/devcontainer.json` file in the `core` repository.
*Make sure that you exclude the change to `.devcontainer/devcontainer.json` from any PRs as it points to local `frontend` repository path.*
58
+
3. Rebuild the Core devcontainer by running the `Dev Containers: Rebuild Container` command in Visual Studio Code to pickup the new `mounts` configuration if you used it before making the change.
59
+
4. Update the Home Assistant configuration to point to the mounted `frontend` path.
43
60
44
-
The Home Assistant's devcontainer needs to get rebuilt via the `docker-build` [task](/development_environment.mdx#tasks), and the `configuration.yaml` should point to the path inside the container:
61
+
```yaml
62
+
frontend:
63
+
development_repo: /workspaces/frontend/
64
+
```
45
65
46
-
```yaml
47
-
frontend:
48
-
development_repo: /workspaces/frontend/
49
-
```
66
+
## Setup Manually
50
67
51
-
The change to `.devcontainer/devcontainer.json` should be excluded from any PR as it contains your local path to the `frontend` repository.
68
+
**Getting Started:**
52
69
53
-
### Installing Node.js
70
+
1. Fork and clone the [Home Assistant frontend repository][hass-frontend].
71
+
2. Install Node.js
72
+
73
+
The preferred method is using [nvm](https://github.com/creationix/nvm). Follow the [nvm installation instructions](https://github.com/creationix/nvm#install-script) and then use it to install Node.js by runnig
54
74
55
-
Node.js is required to build the frontend. The preferred method of installing node.js is with [nvm](https://github.com/creationix/nvm). Install nvm using the instructions in the [README](https://github.com/creationix/nvm#install-script), and install the correct node.js by running the following command:
75
+
```shell
76
+
nvm install
77
+
nvm use
78
+
```
79
+
80
+
This installs the version of Node.js defined in the `.nvmrc` file and then sets it as the current active version.
81
+
82
+
If you're running on Windows, you will need to use an alternative version of nvm like [nvm-windows](https://github.com/coreybutler/nvm-windows). This version of nvm doesn't automatically pickup `.nvmrc` so you'll need to manually select the correct version.
83
+
3. Install [Yarn](https://yarnpkg.com/en/), the package manager used by the frontend, using the [installation instructions](https://yarnpkg.com/en/docs/install)
84
+
4. Install all of the development dependencies by running:
56
85
57
-
```shell
58
-
nvm install
59
-
```
86
+
```shell
87
+
script/bootstrap
88
+
```
60
89
61
-
[Yarn](https://yarnpkg.com/en/) is used as the package manager for node modules. [Install yarn using the instructions here.](https://yarnpkg.com/en/docs/install)
90
+
**Configuring Home Assistant:**
62
91
63
-
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:
92
+
*These instructions assume that you are also [manually running Home Assistant](https://developers.home-assistant.io/docs/development_environment#manual-environment)*
64
93
65
-
```shell
66
-
nvm use
67
-
script/bootstrap
94
+
Update the `frontend` configuration section in your `configuration.yaml` to point to the path of the `frontend` repository you cloned
95
+
96
+
```yaml
97
+
frontend:
98
+
# Example absolute path: /home/paulus/dev/hass/frontend
99
+
development_repo: /path/to/hass/frontend/
68
100
```
69
101
70
102
## Development
71
103
72
-
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:
104
+
Whenever you make changes to files during development, you need to rebuild the development environment so that the Home Assistant instance will pickup the changes. The `script/develop` script will monitor and auto-update the build whenever anything changes.
73
105
74
106
```shell
75
-
nvm use
76
107
script/develop
77
108
```
78
109
79
-
Make sure you have cache disabled and correct settings to avoid stale content:
110
+
Many files will be cached by your web browser so you should disable caching to avoid stale content:
0 commit comments