Skip to content

Commit 3c9a174

Browse files
committed
some frontend cleanup
1 parent 294b9bb commit 3c9a174

25 files changed

+2142
-1233
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ GO_BUILDFLAGS =
3737
GO_LDFLAGS = -s -w
3838

3939
$(CMD): generate www
40-
$(GO) install $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' '$(PKG)'
40+
$(GO) build $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' '$(PKG)'
4141

4242

4343
################################################################################

generate.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gofmt -w server.gen.go server.gen.go
88
echo "generated server.gen.go"
99

1010
oto -template templates/client.js.plush \
11-
-out www/src/client.gen.js \
11+
-out www/src/components/client.gen.js \
1212
-pkg main \
1313
./def
1414
echo "generated client.gen.js"

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func main() {
8989
logg, server, conferenceService)
9090

9191
tracedRouter.Handle("/oto/", server)
92-
spa := spaHandler{staticPath: "./www/public", indexPath: "index.html"}
92+
spa := spaHandler{staticPath: "./www/build", indexPath: "index.html"}
9393

9494
tracedRouter.Mux.Handle("/metrics", promhttp.Handler()) // Prometheus
9595
tracedRouter.Mux.PathPrefix("/").Handler(spa)

www/.gitignore

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/node_modules/
2-
/public/build/
3-
41
.DS_Store
5-
.env
6-
.envrc
7-
2+
node_modules
3+
/.svelte
4+
/build
5+
/functions

www/README.md

+21-85
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,41 @@
1-
*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
1+
# create-svelte
22

3-
---
3+
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);
44

5-
# svelte app
5+
## Creating a project
66

7-
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8-
9-
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
7+
If you're seeing this, you've probably already done this step. Congrats!
108

119
```bash
12-
npx degit sveltejs/template svelte-app
13-
cd svelte-app
14-
```
15-
16-
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
17-
18-
19-
## Get started
20-
21-
Install the dependencies...
10+
# create a new project in the current directory
11+
npm init svelte@next
2212

23-
```bash
24-
cd svelte-app
25-
npm install
26-
```
27-
28-
...then start [Rollup](https://rollupjs.org):
29-
30-
```bash
31-
npm run dev
13+
# create a new project in my-app
14+
npm init svelte@next my-app
3215
```
3316

34-
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35-
36-
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
17+
> Note: the `@next` is temporary
3718
38-
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
3919

40-
## Building and running in production mode
20+
## Developing
4121

42-
To create an optimised version of the app:
22+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
4323

4424
```bash
45-
npm run build
46-
```
47-
48-
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49-
50-
51-
## Single-page app mode
52-
53-
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54-
55-
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56-
57-
```js
58-
"start": "sirv public --single"
59-
```
60-
61-
## Using TypeScript
62-
63-
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64-
65-
```bash
66-
node scripts/setupTypeScript.js
67-
```
68-
69-
Or remove the script via:
70-
71-
```bash
72-
rm scripts/setupTypeScript.js
73-
```
74-
75-
## Deploying to the web
76-
77-
### With [Vercel](https://vercel.com)
78-
79-
Install `vercel` if you haven't already:
80-
81-
```bash
82-
npm install -g vercel
83-
```
84-
85-
Then, from within your project folder:
25+
npm run dev
8626

87-
```bash
88-
cd public
89-
vercel deploy --name my-project
27+
# or start the server and open the app in a new browser tab
28+
npm run dev -- --open
9029
```
9130

92-
### With [surge](https://surge.sh/)
9331

94-
Install `surge` if you haven't already:
32+
## Building
9533

96-
```bash
97-
npm install -g surge
98-
```
34+
Svelte apps are built with *adapters*, which optimise your project for deployment to different environments, like [Begin](https://begin.com), [Netlify](https://www.netlify.com), [Vercel](https://vercel.com) and so on. (You can also create your own adapter — instructions TODO.)
9935

100-
Then, from within your project folder:
36+
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, install it and update your `svelte.config.js` accordingly. The following official adapters are available:
10137

102-
```bash
103-
npm run build
104-
surge public my-project.surge.sh
105-
```
38+
* [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
39+
* [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
40+
* [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
41+
* ...more soon

0 commit comments

Comments
 (0)