LoginSignup
2
2

More than 1 year has passed since last update.

SvelteKit を使った静的サイトへのデプロイ

Last updated at Posted at 2022-11-01

はじめに

先日、以下の投稿で、SvelteKitを使いましたが、今回は実際に
静的サイトとしてデプロイするための準備について記載します。

Adapters

公式サイトによると、デプロイする前に環境に合わせて設定をする必要があるようです。

静的サイトにデプロイするための準備

インストール

アダプターを使うため、インストールをします。

npm install -D @sveltejs/adapter-static

設定を修正する

svelte.config.js ファイルを、以下のように修正します。

- import adapter from '@sveltejs/adapter-auto';
+ import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	preprocess: [
		preprocess({
		  postcss: true,
		}),
	  ],

	kit: {
-		adapter: adapter()
+		adapter: adapter({
+    		pages: 'build',
+			assets: 'build',
+			fallback: 'index.html',
+			precompress: false,
+			strict: true
+		})
	}
};

export default config;

ビルドする

設定は以上です。ここまで終わったらビルドしましょう。

npm run build

こんな風に、index.htmlが生成されていればOKです。
image.png

最後に

無事、静的コンテンツにすることができました。
この後は、これをSpring Bootに組み込んで、みたいと思っています。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2