diff --git a/tsconfig.json b/tsconfig.json index 920a572..a5479f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,13 @@ "skipLibCheck": true, "noUnusedLocals": false, "lib": ["DOM", "DOM.Iterable", "ESNext", "WebWorker"], - "types": ["@webgpu/types", "@types/node", "bun-types"] + "types": ["@webgpu/types", "@types/node", "bun-types"], + "baseUrl": ".", + "paths": { + "@lib/*": ["lib/*"], + "@labs/*": ["labs/*"], + "@propagators/*": ["propagators/*"] + } }, "include": ["lib/**/*.ts", "website/**/*.ts", "vite.config.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 5307805..8e79bb9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,7 +2,7 @@ import { resolve } from 'node:path'; import { readdirSync } from 'node:fs'; import { defineConfig, IndexHtmlTransformContext, Plugin } from 'vite'; -const canvasWebsiteDir = resolve(__dirname, 'website/canvas'); +const canvasWebsiteDir = resolve(__dirname, './website/canvas'); function getCanvasFiles() { return readdirSync(canvasWebsiteDir).filter((file) => file.endsWith('.html')); @@ -65,12 +65,19 @@ const linkGenerator = (): Plugin => { export default defineConfig({ root: 'website', + resolve: { + alias: { + '@lib': resolve(__dirname, './lib'), + '@labs': resolve(__dirname, './labs'), + '@propagators': resolve(__dirname, './labs'), + }, + }, plugins: [linkGenerator()], build: { target: 'esnext', rollupOptions: { input: { - index: resolve(__dirname, 'website/index.html'), + index: resolve(__dirname, './website/index.html'), ...getCanvasFiles().reduce((acc, file) => { acc[`canvas/${file.replace('.html', '')}`] = resolve(canvasWebsiteDir, file); return acc; diff --git a/website/canvas/src/folk-metronome.ts b/website/canvas/src/folk-metronome.ts index e1e2ca2..00e726a 100644 --- a/website/canvas/src/folk-metronome.ts +++ b/website/canvas/src/folk-metronome.ts @@ -1,4 +1,4 @@ -import { FolkElement } from '../../../lib/common/folk-element'; +import { FolkElement } from '@lib/common/folk-element'; declare global { interface HTMLElementTagNameMap { diff --git a/website/canvas/src/folk-timer.ts b/website/canvas/src/folk-timer.ts index 8114a9c..1ec6494 100644 --- a/website/canvas/src/folk-timer.ts +++ b/website/canvas/src/folk-timer.ts @@ -1,4 +1,4 @@ -import { FolkElement } from '../../../lib/common/folk-element'; +import { FolkElement } from '@lib/common/folk-element'; declare global { interface HTMLElementTagNameMap { diff --git a/website/canvas/src/folk-weather.ts b/website/canvas/src/folk-weather.ts index 57dee29..fec4e0a 100644 --- a/website/canvas/src/folk-weather.ts +++ b/website/canvas/src/folk-weather.ts @@ -1,4 +1,4 @@ -import { html } from '../../../lib/common/tags'; +import { html } from '@lib/common/tags'; interface Weather { temperature: string; diff --git a/website/canvas/src/record-player.ts b/website/canvas/src/record-player.ts index 1b46408..d467bad 100644 --- a/website/canvas/src/record-player.ts +++ b/website/canvas/src/record-player.ts @@ -1,5 +1,5 @@ // Ported from https://github.com/bitu467/record-player -import { css, html } from '../../../lib/common/tags'; +import { css, html } from '@lib/common/tags'; const styles = css` ::slotted(*) {