This is a project template for Svelte apps. It lives at https://github.com/Goodstuph/svelte-starter-kit.
To create a new project based on this template using degit:
npx degit Goodstuph/svelte-starter-kit svelte-app
cd svelte-app
Note that you will need to have Node.js installed.
Install the dependencies...
cd svelte-app
npm install
...then start Rollup:
npm run dev
Navigate to localhost:5000. You should see your app running. Edit a component file in src
, save it, and reload the page to see your changes.
There are some differences from the official svelte template. For instance, we have added functionality akin to env variables in the rollup.config.js
file. It basically offers replacements.
Additionally, we've set this up to use svelte-preprocess
to use scss. There is a global scss file in the styles
folder. Everything in that file will be pre-pended to the code. You can also add multiple more files and just import it into the global file.
Routing has been added through svelte-routing.
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 an optimised version of the app:
npm run build
You can run the newly built app with npm run start
. This uses sirv, which is included in your package.json's dependencies
.
[] separate branch for layout component [] separate branch to show usage with Stores
Install vercel
if you haven't already:
npm install -g vercel
Then, from within your project folder:
cd public
vercel deploy --name my-project
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