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:
@@ -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}']
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user