chore: use vite for auto building @nodarium/ui instead of chokidar

We already use vite for building and during dev. Can use a custom vite
plugin to automatically package ui after every change, so no need for
chokidar.
This commit is contained in:
Max Richter
2026-02-03 12:14:58 +01:00
parent a28f15c256
commit 89e4cf8364
4 changed files with 26 additions and 203 deletions

View File

@@ -2,8 +2,7 @@
"name": "@nodarium/ui",
"version": "0.0.1",
"scripts": {
"dev": "chokidar './src/**' --initial -c 'pnpm build'",
"dev:ui": "vite",
"dev": "vite",
"build": "vite build && npm run package",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
@@ -43,7 +42,6 @@
"@types/three": "^0.182.0",
"@typescript-eslint/eslint-plugin": "^8.53.0",
"@typescript-eslint/parser": "^8.53.0",
"chokidar-cli": "^3.0.0",
"dprint": "^0.51.1",
"eslint": "^9.39.2",
"eslint-plugin-svelte": "^3.14.0",
@@ -62,6 +60,8 @@
"types": "./dist/index.d.ts",
"type": "module",
"dependencies": {
"@iconify-json/tabler": "^1.2.26",
"@iconify/tailwind4": "^1.2.1",
"@tailwindcss/vite": "^4.1.18",
"@threlte/core": "^8.3.1",
"@threlte/extras": "^9.7.1",

View File

@@ -1,9 +1,25 @@
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { exec } from 'node:child_process';
import { readFileSync } from 'node:fs';
import { defineConfig } from 'vitest/config';
const postDevPackagePlugin = () => {
const packageContent = JSON.parse(readFileSync('./package.json', { encoding: 'utf8' }));
let timeout: ReturnType<typeof setTimeout> | undefined;
return {
name: 'run-command-on-change',
handleHotUpdate: () => {
clearTimeout(timeout);
timeout = setTimeout(function() {
exec(packageContent.scripts.package);
}, 200);
}
} as const;
};
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
plugins: [tailwindcss(), sveltekit(), postDevPackagePlugin()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}