@@ -3,30 +3,36 @@ import react from "@vitejs/plugin-react";
3
3
import path from "path" ;
4
4
5
5
// 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
+ } ,
28
34
} ,
29
35
} ,
30
36
} ,
31
- } ,
37
+ } ;
32
38
} ) ;
0 commit comments