egoist / tsup

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

Why doesn't the flag --env.NODE_ENV and the option --onSuccess take effect? #1108

Open Crownico opened 2 months ago

Crownico commented 2 months ago

I would like the generated results to be automatically executed following the successful completion of the compilation process, and for that compilation to utilize the configuration corresponding to the specific environment.

"scripts": {
    "dev": "tsup --watch --env.NODE_ENV development --onSuccess 'node dist/app.js'"
}
// tsup.config.ts
import { defineConfig } from "tsup";

const isDev = process.env.NODE_ENV === "development";

console.log("isDev", process.env.NODE_ENV); 

export default defineConfig({
    target: "es2020",
    entry: ["lib/app.ts"],
    outDir: "dist",
    format: ["cjs", "esm"],
    dts: !isDev,
    minify: !isDev,
    clean: true,
    sourcemap: isDev
});

result:

image

Why doesn't the flag --env.NODE_ENV and the option --onSuccess take effect? What should I do?

Upvote & Fund

Fund with Polar