Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stroblp/svelte-gh-pages

quick tutorial about deploying svelte apps to GitHub pages
https://github.com/stroblp/svelte-gh-pages

deployment github-pages svelte

Last synced: 11 days ago
JSON representation

quick tutorial about deploying svelte apps to GitHub pages

Awesome Lists containing this project

README

        

# Deploying Svelte App to GitHub Pages

# Introduction

Short turorial to deploy Svelte app to GitHub Pages.

# svelte app

Create Svelte app

```
npm create vite@latest
```

### Install the `gh-pages` npm package

Install the [`gh-pages`](https://github.com/tschaub/gh-pages) npm package

```
$ npm install gh-pages --save-dev
```

Follow instructions

### Add a `homepage` property to the `package.json` file

Add a `homepage` property in this format\*: `https://{username}.github.io/{repo-name}`

```
"name": "svelte-app",
"version": "0.1.0",
"homepage": "https://{username}.github.io/{repo-name}",
"private": true,
```

### Add base url in `vite.conf.js`
```
export default defineConfig({
plugins: [svelte()],
base:"/{repo-name}/"
})
```
### Add deploy to the `package.json` file

Add a `deploy` to the `scripts` object:

```
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "gh-pages -d dist"
}
```

### Deploy the Svelte app to GitHub Pages

Build and deploy the Svelte app to GitHub Pages

```
npm run build
npm run deploy
```

### The end

[`deployed svelte app`](https://stroblp.github.io/svelte-gh-pages/)