A cool little webapp that I made with Svelte!
Try it out: https://jimlynchcodes.github.io/Jims-Lil-Svelte-Website/
Please use node v12.16.1 (just because that's what I used when beginning this project):
nvm use
To start local Rollup HMR server:
npm run dev
Then you can visit the site at: http://localhost:5000
Note: 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
.
To create a production build:
npm run build
Note: You can run the newly built app with npm run start
. This uses sirv, which is included in your package.json's dependencies
so that the app will work when you deploy to platforms like Heroku.
By default, sirv will only respond to requests that match files in public
. This is to maximize 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:
"start": "sirv public --single"
Run this command, and it should push your "public" folder to the gh-pages branch.
npm run deploy-gh
For my project, it then updates the site here: https://jimlynchcodes.github.io/Jims-Lil-Svelte-Website/
The default Svelte README I started with for this project had these instructions for deploying to zeit and surge. I only deployed to gh-pages, but I figured this might be usedful so I included them here.
Install now
if you haven't already:
npm install -g now
Then, from within your project folder:
cd public
now deploy --name my-project
As an alternative, use the Now desktop client and simply drag the unzipped project folder to the taskbar icon.
Install surge
if you haven't already:
npm install -g surge
Then, from within your project folder:
npm run build
surge public my-project.surge.sh
This proejct was created with the degit Svelte cli:
npx degit sveltejs/template svelte-app