From a737a13e694f4197156c2f90aed0912bce798237 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:02:27 +1100 Subject: [PATCH] feat: Add option to specify build output directory (#46) --- src/build/index.d.ts | 2 ++ src/build/index.js | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/build/index.d.ts b/src/build/index.d.ts index b5a2c60..5d939b3 100644 --- a/src/build/index.d.ts +++ b/src/build/index.d.ts @@ -7,6 +7,8 @@ export type Options = { srcDir: string /** Excluded from type generation, e.g. `[./src/tests]` */ exclude?: string[] + /** Directory where build output will be placed, e.g. `./dist` */ + outDir?: string } export function tanstackBuildConfig(config: Options): UserConfig diff --git a/src/build/index.js b/src/build/index.js index 25ac567..208c907 100644 --- a/src/build/index.js +++ b/src/build/index.js @@ -10,12 +10,14 @@ import dts from 'vite-plugin-dts' * @returns {import('vite').UserConfig} */ export const tanstackBuildConfig = (options) => { + const outDir = options.outDir ?? 'dist' + return defineConfig({ plugins: [ externalizeDeps(), preserveDirectives(), dts({ - outDir: 'dist/esm', + outDir: `${outDir}/esm`, entryRoot: options.srcDir, include: options.srcDir, exclude: options.exclude, @@ -34,7 +36,7 @@ export const tanstackBuildConfig = (options) => { }, }), dts({ - outDir: 'dist/cjs', + outDir: `${outDir}/cjs`, entryRoot: options.srcDir, include: options.srcDir, exclude: options.exclude, @@ -56,7 +58,7 @@ export const tanstackBuildConfig = (options) => { }), ], build: { - outDir: 'dist', + outDir, minify: false, sourcemap: true, lib: {