chore(config): migrate build toolchain from React to Svelte

- Replace React/Vite plugins with Svelte plugin
- Update tsconfig presets for Svelte
- Clean up obsolete dependencies and build config
- Add *.tsbuildinfo to .gitignore
This commit is contained in:
Uglyboy 2026-05-06 09:15:55 +08:00
parent 69c68b77bb
commit a0b97b90db
4 changed files with 17 additions and 35 deletions

3
.gitignore vendored
View file

@ -21,3 +21,6 @@ data.json
# Exclude macOS Finder (System Explorer) View States
.DS_Store
# TypeScript
*.tsbuildinfo

View file

@ -4,7 +4,7 @@
"description": "Playing interactive fiction powered by Inkle's ink engine",
"main": "main.js",
"scripts": {
"clean": "rm -rf node_modules dist/main.js dist/styles.css package-lock.json bun.lock",
"clean": "rm -rf node_modules dist/main.js dist/styles.css bun.lock",
"build": "vite build",
"check": "biome check --write --error-on-warnings . && tsgo -b --noEmit",
"release": "bun run scripts/release.mjs"
@ -13,23 +13,20 @@
"author": "Uglyboy",
"license": "MIT",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@tsconfig/bun": "^1.0.0",
"@tsconfig/vite-react": "^7.0.0",
"@tsconfig/svelte": "^5.0.0",
"@types/mustache": "^4.2.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@vitejs/plugin-react": "^6.0.0",
"esbuild": "^0.28.0",
"svelte": "^5.0.0",
"vite": "^8.0.0"
},
"dependencies": {
"@inkweave/core": "^2.0.4",
"@inkweave/plugins": "^2.0.4",
"@inkweave/react": "^2.0.4",
"@inkweave/svelte": "^2.0.4",
"zustand": "^5.0.0",
"mustache": "^4.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"mustache": "^4.2.0"
},
"peerDependencies": {
"obsidian": ">=0.15.0"

View file

@ -1,6 +1,6 @@
{
"$schema": "https://www.schemastore.org/tsconfig",
"extends": ["@tsconfig/bun/tsconfig.json", "@tsconfig/vite-react/tsconfig.json"],
"extends": ["@tsconfig/bun/tsconfig.json", "@tsconfig/svelte/tsconfig.json"],
"compilerOptions": {
"types": ["bun-types"]
},

View file

@ -1,14 +1,11 @@
import { builtinModules } from "node:module";
import { resolve } from "node:path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { svelte } from "@sveltejs/vite-plugin-svelte";
const processPolyfill = `if(typeof window!=="undefined"&&typeof window.process==="undefined"){window.process={env:{NODE_ENV:"production"},browser:true}}`;
export default defineConfig({
export default defineConfig(({ mode }) => ({
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
"process.env.NODE_ENV": JSON.stringify(mode || "production"),
},
build: {
lib: {
@ -18,26 +15,13 @@ export default defineConfig({
},
rollupOptions: {
external: [
// Obsidian
"obsidian",
"electron",
// CodeMirror
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
// Node builtins
/^@codemirror\//,
/^@lezer\//,
...builtinModules,
],
output: {
banner: processPolyfill,
exports: "default",
assetFileNames: "styles.css",
},
@ -48,7 +32,5 @@ export default defineConfig({
cssMinify: "esbuild",
emptyOutDir: true,
},
plugins: [
react(),
],
});
plugins: [svelte()],
}));