diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 0277bb81..cd46171f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -3,7 +3,8 @@ "allow": [ "Bash(find node_modules/.pnpm -path */start-plugin-core/dist/esm/index.d.ts)", "Bash(find node_modules/.pnpm -path */start-plugin-core/dist/esm/*.d.ts)", - "Bash(NITRO_PRESET=cloudflare-pages pnpm build)" + "Bash(NITRO_PRESET=cloudflare-pages pnpm build)", + "Bash(timeout 12 npx wrangler pages dev .)" ] } } diff --git a/package.json b/package.json index 8f64fec1..9b840079 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "dev": "vite dev", - "build": "lingui compile && vite build", + "build": "lingui compile && vite build && node scripts/clean-worker-statics.mjs", "build:analyze": "ANALYZE=true lingui compile && vite build", "serve": "vite preview", "format": "biome format", diff --git a/scripts/clean-worker-statics.mjs b/scripts/clean-worker-statics.mjs new file mode 100644 index 00000000..73f84124 --- /dev/null +++ b/scripts/clean-worker-statics.mjs @@ -0,0 +1,11 @@ +import { readdirSync, rmSync } from 'node:fs' +import { join } from 'node:path' + +const workerDir = 'dist/_worker.js' +const keep = new Set(['index.js', 'wrangler.json', 'chunks']) + +for (const entry of readdirSync(workerDir)) { + if (!keep.has(entry)) { + rmSync(join(workerDir, entry), { recursive: true, force: true }) + } +} diff --git a/vite.config.ts b/vite.config.ts index 048b1381..c434b333 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -119,6 +119,9 @@ const config = defineConfig({ compressPublicAssets: true, minify: true, rollupConfig: { + output: { + inlineDynamicImports: true, + }, treeshake: { moduleSideEffects: false, propertyReadSideEffects: false,