chore(core): 搭建 yggdrasil-core 子工程骨架

照搬 lightbox 的 Vite IIFE 工程结构,作为核心 JS 统一归处。
此 commit 仅打通构建管线,业务逻辑后续 task 填入。
同时把 public/yggdrasil-core 加入根 .gitignore。
This commit is contained in:
xfy 2026-06-26 13:51:39 +08:00
parent 731547e6df
commit afabdf4655
9 changed files with 1505 additions and 0 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ public/style.css
public/highlight.css
public/tiptap
public/lightbox
public/yggdrasil-core
public/doc
/static
.env

1
libs/yggdrasil-core/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

1422
libs/yggdrasil-core/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
{
"name": "@yggdrasil/core",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "tsc --noEmit && vite build",
"dev": "vite",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
"devDependencies": {
"happy-dom": "^20.10.6",
"typescript": "^6.0.3",
"vite": "^8.1.0",
"vitest": "^4.1.9"
}
}

View File

@ -0,0 +1,11 @@
declare global {
interface Window {
__initPostContent: (selector: string) => void;
}
}
window.__initPostContent = (_selector: string): void => {
// Task 2 实现
};
export {};

1
libs/yggdrasil-core/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"skipLibCheck": true,
"esModuleInterop": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"types": []
},
"include": ["src"]
}

View File

@ -0,0 +1,23 @@
import { defineConfig } from 'vite';
import { resolve } from 'path';
export default defineConfig({
build: {
outDir: resolve(__dirname, '../../public/yggdrasil-core'),
emptyOutDir: true,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'YggdrasilCore',
fileName: () => 'yggdrasil-core.js',
formats: ['iife'],
},
rolldownOptions: {
output: {
assetFileNames: 'yggdrasil-core.[ext]',
},
},
cssCodeSplit: false,
minify: true,
sourcemap: true,
},
});

View File

@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
environment: 'happy-dom',
include: ['src/**/*.test.ts'],
},
});