Skip to content

Output Based on Filename? #793

Answered by Crisfole
Crisfole asked this question in Q&A
Dec 5, 2022 · 1 comments · 7 replies
Discussion options

You must be logged in to vote

OK, so as tradition requires, I figured this out shortly after posting this.

tsup accepts multiple configs and allows passing esbuildOptions. The solution:

import { defineConfig } from 'tsup'

export default defineConfig([
	{
		entry: [
			"src/*.ts",
		],
		dts: true,
		format: 'esm',
		splitting: false,
		sourcemap: true,
		clean: true,
		esbuildOptions(opts, ctx) {
			opts.entryNames = "[dir]/[name]/index"
		}
	},
	{
		entry: [
			"src/*/+(index|worker|*.worker).ts",
		],
		dts: true,
		format: 'esm',
		splitting: false,
		sourcemap: true,
		clean: true,
	}
])

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@RodrigoNovais
Comment options

@Crisfole
Comment options

@SonNg2k
Comment options

@Crisfole
Comment options

@brianjenkins94
Comment options

Answer selected by Crisfole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants