mirror of
https://github.com/penpot/penpot.git
synced 2026-09-14 16:09:01 +00:00
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
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { defineConfig, type UserConfig } from 'vite';
|
|
|
|
/**
|
|
* Shared config for the two single-file IIFE bundles (`headless.js`,
|
|
* `tests-bundle.js`). Both are self-executing chunks with no `import`/`export`
|
|
* statements so they can be evaluated directly inside the Penpot plugin sandbox
|
|
* (via `globalThis.ɵloadPlugin({ code })` for headless, or the UI "Reload"
|
|
* button's `eval` for the tests bundle). They differ only by their entry module.
|
|
*
|
|
* `emptyOutDir` stays false so a `watch` rebuild of one bundle never wipes the
|
|
* sibling outputs in the shared `dist` directory.
|
|
*/
|
|
export function iifeConfig(name: string, entry: string): UserConfig {
|
|
return defineConfig({
|
|
root: import.meta.dirname,
|
|
resolve: {
|
|
tsconfigPaths: true,
|
|
},
|
|
build: {
|
|
outDir: '../../dist/apps/plugin-api-test-suite',
|
|
emptyOutDir: false,
|
|
reportCompressedSize: false,
|
|
rollupOptions: {
|
|
input: {
|
|
[name]: entry,
|
|
},
|
|
output: {
|
|
format: 'iife',
|
|
entryFileNames: '[name].js',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|