Open4
SvelteでLogseqプラグイン開発
SvelteKitでもSPAを作れるみたいなのでsveltekitにしました。
bunx sv create sveltekit-plugin
┌ Welcome to the Svelte CLI! (v0.8.3)
│
◇ Which template would you like?
│ SvelteKit minimal
│
◇ Add type checking with TypeScript?
│ Yes, using TypeScript syntax
│
◆ Project created
│
◇ What would you like to add to your project? (use arrow keys / space bar)
│ eslint, playwright
│
◆ Successfully setup add-ons
│
◇ Which package manager do you want to install dependencies with?
│ bun
│
◆ Successfully installed dependencies
│
◇ Project next steps ─────────────────────────────────────────────────────╮
│ │
│ 1: cd sveltekit-plugin │
│ 2: git init && git add -A && git commit -m "Initial commit" (optional) │
│ 3: bun run dev --open │
│ │
│ To close the dev server, hit Ctrl-C │
│ │
│ Stuck? Visit us at https://svelte.dev/chat │
│ │
├──────────────────────────────────────────────────────────────────────────╯
│
└ You're all set!
SPAにするための設定
そしてSPAにするために次のファイルを作成します。
src/routes/+layout.ts
export const ssr = false;
static-adapter
をインストールします。bun add -D @sveltejs/adapter-static
を実行。svelte.config.js
にこの adapter を追加。
svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
+ adapter: adapter({
+ pages: 'build',
+ assets: 'build',
+ fallback: undefined,
+ precompress: false,
+ strict: true
+ })
}
};
export default config;
SvelteKitではいきづまった。今度はsvelteのみでやってみよう。