Andrey Antukh 05ea09f2ba ♻️ Make vite configs compatible with the native config loader
Replace __dirname with import.meta.dirname in the plugins workspace
vite configs (root paths and the plugins-runtime tsconfigPath) and in
frontend/vite.config.js, dropping the fileURLToPath fallback.

Import vite.config.iife with the explicit .ts extension in the
plugin-api-test-suite headless/tests configs and allow it in
tsconfig.node.json (moduleResolution Bundler + noEmit), matching the
mcp/packages/plugin precedent.

Remove .storybook/vitest.setup.ts and its setupFiles entry;
@storybook/addon-vitest 10.3+ provisions preview annotations
automatically.

These clear the Vite `configLoader: 'native'` warnings ahead of that
loader becoming the default.

AI-assisted-by: omen-alpha
2026-09-09 08:04:11 +02:00

44 lines
1.1 KiB
TypeScript

/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
export default defineConfig({
root: import.meta.dirname,
// Emit relative asset URLs in index.html so the built plugin works when served
// from a subdirectory (Penpot serves the bundled plugins under `/plugins/...`).
// Vite resolves `./` to `/` for the dev server, so `pnpm run dev` is unaffected.
base: './',
server: {
port: 4202,
host: '0.0.0.0',
cors: true,
},
preview: {
port: 4202,
host: '0.0.0.0',
cors: true,
},
resolve: {
tsconfigPaths: true,
},
build: {
outDir: '../../dist/apps/plugin-api-test-suite',
// Keep false so `watch` rebuilds don't wipe the sibling tests-bundle.js /
// headless.js outputs. The `build` script passes --emptyOutDir for a clean
// one-shot build.
emptyOutDir: false,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
input: {
plugin: 'src/plugin.ts',
index: './index.html',
},
output: {
entryFileNames: '[name].js',
},
},
},
});