-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Chi-EEE/svelte-spa-router
Fix RPLidar & Use Svelte-SPA-Router
- Loading branch information
Showing
38 changed files
with
670 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
.DS_Store | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.svelte-kit |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["svelte.svelte-vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,53 @@ | ||
# create-svelte | ||
<table> | ||
<tr> | ||
<td> | ||
<a href="https://www.amazon.com/dp/B08D6T6BKS/"><img src="https://static.packt-cdn.com/products/9781839213625/cover/smaller" width="120" /></a> | ||
</td> | ||
<td> | ||
<h3>Svelte 3 Up and Running</h3> | ||
<p>Want to learn Svelte 3 and how to build a Single-Page App (SPA) with it (and with this router)? Check out my book <a href="https://www.amazon.com/dp/B08D6T6BKS/">Svelte 3 Up and Running</a> on Amazon.</p> | ||
</td> | ||
</table> | ||
|
||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). | ||
# Svelte app with svelte-spa-router | ||
|
||
## Creating a project | ||
This is a project template for [Svelte 4](https://svelte.dev) apps that includes [svelte-spa-router](https://github.com/italypaleale/svelte-spa-router) for client-side routing, TypeScript, and Vite as bundler. | ||
|
||
If you're seeing this, you've probably already done this step. Congrats! | ||
## About svelte-spa-router | ||
|
||
```bash | ||
# create a new project in the current directory | ||
npm create svelte@latest | ||
svelte-spa-router is a client-side router for Svelte 4 apps that leverages hash-based routing (i.e. stores the current view in the URL after the `#` symbol). | ||
|
||
# create a new project in my-app | ||
npm create svelte@latest my-app | ||
``` | ||
You can read more about the router, and the reasons why you might want to use hash-based routing (or not), in the [documentation](https://github.com/italypaleale/svelte-spa-router). | ||
|
||
## Developing | ||
## Get started | ||
|
||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: | ||
Install the dependencies… | ||
|
||
```bash | ||
npm run dev | ||
cd svelte-app | ||
npm install | ||
``` | ||
|
||
…then start a dev server using [Vite](https://vite.dev): | ||
|
||
# or start the server and open the app in a new browser tab | ||
npm run dev -- --open | ||
```bash | ||
npm run dev | ||
``` | ||
|
||
## Building | ||
Navigate to [http://localhost:5050](http://localhost:5050). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes. | ||
|
||
You can add more routes by defining them in the [`src/routes.ts`](./src/routes.ts) file. More information can be found on the [documentation for svelte-spa-router](https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/README.md). | ||
|
||
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `vite` commands in package.json to include the option `--host 0.0.0.0`. | ||
|
||
To create a production version of your app: | ||
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. | ||
|
||
## Building and running in production mode | ||
|
||
To create an optimized version of the app: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
You can preview the production build with `npm run preview`. | ||
|
||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. | ||
You can run the newly-built app with `npm run preview`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/svelte.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Svelte 4 + svelte-spa-router + TypeScript</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
{ | ||
"name": "frontend", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-auto": "^2.1.1", | ||
"@sveltejs/adapter-static": "^2.0.3", | ||
"@sveltejs/kit": "^1.27.7", | ||
"@types/node": "^20.10.4", | ||
"@types/ws": "^8.5.10", | ||
"svelte": "^4.2.8", | ||
"svelte-check": "^3.6.2", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.3.3", | ||
"vite": "^4.5.1", | ||
"ws": "^8.14.2" | ||
}, | ||
"type": "module" | ||
"name": "frontend", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --port 5050", | ||
"build": "vite build", | ||
"preview": "vite preview --port 5050", | ||
"check": "svelte-check --tsconfig ./tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/vite-plugin-svelte": "^3.0.0", | ||
"@tsconfig/svelte": "^5.0.2", | ||
"svelte": "^4.2.3", | ||
"svelte-check": "^3.6.0", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"svelte-spa-router": "^4.0.0" | ||
} | ||
} |
Oops, something went wrong.