lemmy-phpbb-sveltejs/README.md

106 lines
2.8 KiB
Markdown
Raw Normal View History

2020-02-02 17:44:37 +00:00
*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2018-04-03 17:49:11 +00:00
---
2017-08-06 00:20:53 +00:00
# svelte app
2019-05-11 11:25:23 +00:00
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
2017-08-06 00:20:53 +00:00
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
```bash
npx degit sveltejs/template svelte-app
2017-08-06 00:20:53 +00:00
cd svelte-app
```
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
## Get started
Install the dependencies...
```bash
cd svelte-app
npm install
```
2017-08-06 00:23:01 +00:00
...then start [Rollup](https://rollupjs.org):
2017-08-06 00:20:53 +00:00
```bash
npm run dev
```
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.
2019-09-24 02:52:24 +00:00
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`.
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.
2017-08-06 00:20:53 +00:00
## Building and running in production mode
To create an optimised version of the app:
```bash
npm run build
```
2019-11-15 23:21:23 +00:00
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).
## Single-page app mode
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.
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:
```js
"start": "sirv public --single"
```
## Using TypeScript
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
```bash
node scripts/setupTypeScript.js
```
Or remove the script via:
```bash
rm scripts/setupTypeScript.js
```
2017-08-06 00:20:53 +00:00
## Deploying to the web
### With [Vercel](https://vercel.com)
2017-08-06 00:20:53 +00:00
Install `vercel` if you haven't already:
2017-08-06 00:20:53 +00:00
```bash
npm install -g vercel
2017-08-06 00:20:53 +00:00
```
Then, from within your project folder:
```bash
cd public
vercel deploy --name my-project
2017-08-06 00:20:53 +00:00
```
### With [surge](https://surge.sh/)
Install `surge` if you haven't already:
```bash
npm install -g surge
```
Then, from within your project folder:
```bash
npm run build
2019-11-16 16:41:58 +00:00
surge public my-project.surge.sh
2017-08-06 00:23:01 +00:00
```