Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add mechanism to build SPA version of the app #481

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ pnpm build

You can preview the production build with `pnpm preview`.

If you want to create a build that can be statically served, you need to set env `STATIC=TRUE`.

```bash
STATIC=TRUE pnpm build
```

The outcome is in `build` folder.

## Config

Use env variables to specify:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@fontsource/source-sans-pro": "^5.0.4",
"@multiformats/multiaddr": "^12.1.3",
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.21.0",
"@total-typescript/ts-reset": "^0.4.2",
"@typechain/ethers-v6": "^0.5.0",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import adapter from '@sveltejs/adapter-auto'
import adapterStatic from '@sveltejs/adapter-static'
import preprocessor from 'svelte-preprocess'

/** @type {import('@sveltejs/kit').Config} */
Expand All @@ -11,7 +12,14 @@ const config = {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
adapter: process.env.STATIC
? adapterStatic({
// default options are shown
pages: 'build',
assets: 'build',
fallback: 'index.html',
})
: adapter(),
},
}

Expand Down