chore: add internal vite config (#568)

This commit is contained in:
Marco Pasqualetti
2025-02-16 15:39:25 +01:00
committed by GitHub
parent d37b655add
commit 12e0937174
20 changed files with 420 additions and 1195 deletions
+24
View File
@@ -0,0 +1,24 @@
{
"name": "vite-config",
"version": "1.0.0",
"type": "module",
"private": true,
"exports": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"scripts": {
"build": "tsc",
"lint": "eslint .",
"format": "prettier --check --ignore-unknown --ignore-path ../../.prettierignore .",
"format:fix": "prettier --write --ignore-unknown --ignore-path ../../.prettierignore .",
"types": "tsc --noEmit"
},
"devDependencies": {
"oxc-transform": "0.50.0",
"rollup-plugin-preserve-directives": "0.4.0",
"unplugin-isolated-decl": "0.11.0",
"vite": "5.4.14",
"vite-plugin-externalize-deps": "0.9.0"
}
}
+37
View File
@@ -0,0 +1,37 @@
import type { UserConfig } from 'vite'
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
import { externalizeDeps } from 'vite-plugin-externalize-deps'
import UnpluginIsolatedDecl from 'unplugin-isolated-decl/vite'
interface Options {
/** Entry file, e.g. `./src/index.ts` */
entry: string | Array<string>
}
export function defineViteConfig({ entry }: Options): UserConfig {
const outDir = 'dist'
return {
build: {
outDir,
minify: false,
sourcemap: true,
lib: {
entry,
formats: ['es'],
fileName: 'esm/[name]',
},
rollupOptions: {
output: {
preserveModules: true,
entryFileNames: 'esm/[name].js',
},
},
},
plugins: [
externalizeDeps(),
preserveDirectives(),
UnpluginIsolatedDecl({ transformer: 'oxc' }),
],
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"include": ["src"],
"compilerOptions": {
// Modules
"moduleResolution": "node16",
"module": "Node16",
// Emit
"noEmit": false,
"declaration": true,
"outDir": "dist"
}
}