mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
feat: move vite configuration to @tanstack/config package
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"build": "vite build",
|
||||
"lint": "eslint --ext .ts,.tsx ./src -c ../../.eslintrc",
|
||||
"format": "prettier --ignore-unknown '**/*'",
|
||||
"test": "vitest --typecheck --watch=false",
|
||||
"test": "vitest --typecheck --watch=false",
|
||||
"types": "tsc --noEmit"
|
||||
},
|
||||
"exports": {
|
||||
@@ -43,12 +43,10 @@
|
||||
"@babel/template": "^7.24.0",
|
||||
"@babel/traverse": "^7.24.1",
|
||||
"@babel/types": "^7.24.0",
|
||||
"@tanstack/config": "^0.7.0",
|
||||
"@types/babel__core": "^7.20.5",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"rollup-plugin-preserve-directives": "^0.4.0",
|
||||
"vite": "^5.2.10",
|
||||
"vite-plugin-dts": "^3.9.0",
|
||||
"vite-plugin-externalize-deps": "^0.8.0",
|
||||
"vitest": "^1.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,76 +1,13 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import dts from 'vite-plugin-dts'
|
||||
import { externalizeDeps } from 'vite-plugin-externalize-deps'
|
||||
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
|
||||
import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import { tanstackBuildConfig } from '@tanstack/config/build'
|
||||
|
||||
const config = ({ entryRoot, include, exclude }): any =>
|
||||
defineConfig({
|
||||
plugins: [
|
||||
externalizeDeps(),
|
||||
preserveDirectives(),
|
||||
dts({
|
||||
outDir: 'dist/esm',
|
||||
entryRoot,
|
||||
include,
|
||||
exclude,
|
||||
compilerOptions: {
|
||||
// @ts-expect-error
|
||||
module: 'esnext',
|
||||
declarationMap: false,
|
||||
},
|
||||
beforeWriteFile: (filePath, content) => {
|
||||
content = content.replace(
|
||||
/^(im|ex)port\s[\w{}*\s,]+from\s['"]\.\/[^.'"]+(?=['"];?$)/gm,
|
||||
'$&.js',
|
||||
)
|
||||
const config = defineConfig({})
|
||||
|
||||
return { filePath, content }
|
||||
},
|
||||
}),
|
||||
dts({
|
||||
outDir: 'dist/cjs',
|
||||
entryRoot,
|
||||
include,
|
||||
exclude,
|
||||
compilerOptions: {
|
||||
// @ts-expect-error
|
||||
module: 'commonjs',
|
||||
declarationMap: false,
|
||||
},
|
||||
beforeWriteFile: (filePath, content) => {
|
||||
content = content.replace(
|
||||
/^(im|ex)port\s[\w{}*\s,]+from\s['"]\.\/[^.'"]+(?=['"];?$)/gm,
|
||||
'$&.cjs',
|
||||
)
|
||||
|
||||
filePath = filePath.replace('.d.ts', '.d.cts')
|
||||
|
||||
return { filePath, content }
|
||||
},
|
||||
}),
|
||||
],
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
lib: {
|
||||
entry: entryRoot,
|
||||
formats: ['es', 'cjs'],
|
||||
fileName: (format) => {
|
||||
if (format === 'cjs') return 'cjs/[name].cjs'
|
||||
return 'esm/[name].js'
|
||||
},
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
preserveModules: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export default config({
|
||||
entryRoot: './src/index.ts',
|
||||
include: './src',
|
||||
exclude: ['./src/tests/'],
|
||||
})
|
||||
export default mergeConfig(
|
||||
config,
|
||||
tanstackBuildConfig({
|
||||
entry: './src/index.ts',
|
||||
srcDir: './src',
|
||||
exclude: ['./src/tests/'],
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user