Skip to content
This repository was archived by the owner on Jul 20, 2022. It is now read-only.

Commit 551f559

Browse files
prevent vite from replacing NODE_ENV
vitejs/vite#3229 (comment)
1 parent 7ac7b9c commit 551f559

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

vite.config.ts

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,36 @@ import react from "@vitejs/plugin-react";
33
import path from "path";
44

55
// https://vitejs.dev/config/
6-
export default defineConfig({
7-
plugins: [react()],
8-
build: {
9-
emptyOutDir: false,
10-
lib: {
11-
entry: path.resolve(__dirname, "src/index.ts"),
12-
name: "RemixCrash",
13-
fileName: (format) => `remix-crash.${format}.js`,
14-
},
15-
rollupOptions: {
16-
// make sure to externalize deps that shouldn't be bundled
17-
// into your library
18-
external: ["react", "react-dom", "remix", "source-map", "fs/promises"],
19-
output: {
20-
// Provide global variables to use in the UMD build
21-
// for externalized deps
22-
globals: {
23-
react: "React",
24-
"react-dom": "ReactDOM",
25-
remix: "Remix",
26-
"source-map": "SourceMap",
27-
"fs/promises": "FSPromises",
6+
export default defineConfig(({ mode }) => {
7+
return {
8+
plugins: [react()],
9+
define:
10+
mode === "production"
11+
? { "process.env.NODE_ENV": "process.env.NODE_ENV" }
12+
: {},
13+
build: {
14+
emptyOutDir: false,
15+
lib: {
16+
entry: path.resolve(__dirname, "src/index.ts"),
17+
name: "RemixCrash",
18+
fileName: (format) => `remix-crash.${format}.js`,
19+
},
20+
rollupOptions: {
21+
// make sure to externalize deps that shouldn't be bundled
22+
// into your library
23+
external: ["react", "react-dom", "remix", "source-map", "fs/promises"],
24+
output: {
25+
// Provide global variables to use in the UMD build
26+
// for externalized deps
27+
globals: {
28+
react: "React",
29+
"react-dom": "ReactDOM",
30+
remix: "Remix",
31+
"source-map": "SourceMap",
32+
"fs/promises": "FSPromises",
33+
},
2834
},
2935
},
3036
},
31-
},
37+
};
3238
});

0 commit comments

Comments
 (0)