Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.

Commit b0056aa

Browse files
committed
document How to make live reload work in Rollup based projects like Svelte.
Fixes gitpod-io/website#770
1 parent a4f8d2f commit b0056aa

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/docs/languages/javascript.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ and then search for `eslint` in the extensions tab and then install it from ther
6969

7070
![Install Eslint in Gitpod](../images/eslint-extension.png)
7171

72+
## Making Live Reload work in Rollup based projects like Svelte
73+
74+
If your porject uses Rollup as a module bundler then in order for live reload to work in Gitpod you'll have to add a bit of configuration as specified below:
75+
76+
- Setup an environment variable called `CLIENT_URL` in the `.gitpod.yml` config file as shown below please make sure that you set it up before the task which starts the dev server(which is `npm run dev` in this case):
77+
78+
```bash
79+
- init: npm install
80+
command: |
81+
export CLIENT_URL="$(gp url 35729)/livereload.js?snipver=1&port=443"
82+
npm run dev
83+
```
84+
85+
- Pass the value of `CLIENT_URL` environment variable to the `rollup-plugin-livereload` in `rollup-config.js` inside of the `plugins` array as shown:
86+
```js
87+
plugins: [
88+
!production &&
89+
livereload({
90+
watch: 'public',
91+
clientUrl: process.env.CLIENT_URL
92+
})
93+
]
94+
```
95+
This will set `CLIENT_URL` to the workspace url of port `35729` (default port for livereload in Gitpod).
96+
97+
https://github.com/gitpod-io/sveltejs-template repo is a working example of the config described above <span aria-hidden="true">👆</span>.
98+
7299
## Further Reading
73100

74101
- [Sustainable Node.js development with only a browser](/blog/node-js-development/).

0 commit comments

Comments
 (0)