egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.22k stars 219 forks source link

Feature request: Option to produce both minified and non-minified builds #641

Open vforsh opened 2 years ago

vforsh commented 2 years ago

Right now I use an onSuccess callback for this: onSuccess: "esbuild --minify --sourcemap ./dist/lib.js --outfile=./dist/lib.min.js"

But it would be nice to have an option for this.

Thanks for an awesome tool!

Upvote & Fund

Fund with Polar

andreww2012 commented 1 year ago

Workaround: build in two phases (w/ and w/o --minify flag) with the following config:

import {defineConfig} from 'tsup';

export default defineConfig({
  outExtension: ({options, format}) => {
    const formatExtension = [options.minify ? 'min' : '', format].filter(Boolean).join('.');
    return {
      js: `.${formatExtension}.js`,
    };
  },
});