Skip to content

Commit

Permalink
feat: Add option to specify build output directory (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Feb 17, 2024
1 parent 1df0f68 commit a737a13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions src/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -34,7 +36,7 @@ export const tanstackBuildConfig = (options) => {
},
}),
dts({
outDir: 'dist/cjs',
outDir: `${outDir}/cjs`,
entryRoot: options.srcDir,
include: options.srcDir,
exclude: options.exclude,
Expand All @@ -56,7 +58,7 @@ export const tanstackBuildConfig = (options) => {
}),
],
build: {
outDir: 'dist',
outDir,
minify: false,
sourcemap: true,
lib: {
Expand Down

0 comments on commit a737a13

Please sign in to comment.