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

Commit a3a9b78

Browse files
committed
[docs]: Svelte in Gitpod.
Fixes gitpod-io/website#782
1 parent e2ae47f commit a3a9b78

File tree

5 files changed

+64
-27
lines changed

5 files changed

+64
-27
lines changed
131 KB
Loading

src/docs/languages/javascript.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,7 @@ and then search for `eslint` in the extensions tab and then install it from ther
7171

7272
## Making Live Reload work in Rollup based projects like Svelte
7373

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>.
74+
This section was moved into [Svelte guide](/docs/languages/svelte/).
9875

9976
## Further Reading
10077

src/docs/languages/svelte.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Svelte in Gitpod
2+
3+
To work with Svelte in Gitpod, you will need to properly configure your repository. Here is how to do that, assuming that you're using the official sveltejs [template](https://github.com/sveltejs/template) which uses Rollup:
4+
5+
## Create a .gitpod.yml
6+
7+
Start by creating a `.gitpod.yml` file in the root of your project and add the following to it:
8+
9+
```yml
10+
tasks:
11+
- init: npm install
12+
command: npm run dev
13+
14+
ports:
15+
- port: 5000
16+
onOpen: open-preview
17+
- port: 35729
18+
onOpen: ignore
19+
```
20+
21+
After committing and pushing this file to your repository, start a new Gitpod workspace. You'll see that Gitpod will automatically install the dependencies; start the dev server; and open a preview on the side for port `5000`.
22+
23+
![Sveltejs Template in Gitpod](../images/svelte-template-in-gitpod.png)
24+
25+
## Making Live Reload work
26+
27+
In order to make live reload work we need to add a bit of configuration as specified below:
28+
29+
- 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):
30+
31+
```bash
32+
- init: npm install
33+
command: |
34+
export CLIENT_URL="$(gp url 35729)/livereload.js?snipver=1&port=443"
35+
npm run dev
36+
```
37+
38+
- Pass the value of `CLIENT_URL` environment variable to the `rollup-plugin-livereload` in `rollup-config.js` inside of the `plugins` array as shown:
39+
```js
40+
plugins: [
41+
!production &&
42+
livereload({
43+
watch: 'public',
44+
clientUrl: process.env.CLIENT_URL
45+
})
46+
]
47+
```
48+
This will set `CLIENT_URL` to the workspace url of port `35729` (default port for livereload in Gitpod).
49+
50+
## VSCode Extensions
51+
52+
### Svelte for VS Code
53+
54+
Svelte for VS Code Provides syntax highlighting and rich intellisense for Svelte components in VS Code, utilising the [svelte language server](https://github.com/sveltejs/language-tools/tree/master/packages/language-server).
55+
56+
To add this extension to your repository, simply head to Gitpod’s [Extensions panel](https://www.gitpod.io/docs/vscode-extensions/) (find it in the IDE’s left vertical menu), then search for the desired extension by name, and install it for your project. This will add an entry to your [.gitpod.yml](https://www.gitpod.io/docs/config-gitpod-file/) file that ensures all future Gitpod workspaces for your repository will already have this extension pre-installed.
57+
58+
59+
https://github.com/gitpod-io/sveltejs-template repo is a working example of the config described above <span aria-hidden="true">👆</span>.

src/docs/menu.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ export const MENU: MenuEntry[] = [
205205
"Vue",
206206
"languages/vue"
207207
),
208+
M(
209+
"Svelte",
210+
"languages/svelte"
211+
),
208212
M(
209213
"Scala",
210214
"languages/scala"

src/templates/doc.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,3 @@ export const query = graphql`
8585
}
8686
}
8787
`
88-
89-
90-

0 commit comments

Comments
 (0)