1- import { defineConfig } from 'vite'
2- import react from '@vitejs/plugin-react'
3- import { resolve } from 'path'
4- import svgr from 'vite-plugin-svgr'
1+ import { defineConfig } from 'vite' ;
2+ import react from '@vitejs/plugin-react' ;
3+ import path from 'path' ;
4+ import svgr from 'vite-plugin-svgr' ;
5+
6+ const noExternal = [
7+ '@mui/material' ,
8+ '@mui/utils' ,
9+ '@mui/system' ,
10+ '@mui/icons-material' ,
11+ '@mui/styled-engine' ,
12+ '@emotion/react' ,
13+ '@emotion/styled' ,
14+ '@emotion/cache'
15+ ] ;
516
617export default defineConfig ( {
718 plugins : [
819 react ( {
9- jsxRuntime : 'classic'
20+ jsxImportSource : '@emotion/react' ,
21+ babel : {
22+ plugins : [ '@emotion/babel-plugin' ] ,
23+ } ,
1024 } ) ,
1125 svgr ( )
1226 ] ,
27+ define : {
28+ 'process.env.NODE_ENV' : JSON . stringify ( 'production' ) ,
29+ } ,
30+ resolve : {
31+ alias : {
32+ '@' : path . resolve ( __dirname , 'src' ) ,
33+ '@emotion/react' : path . resolve (
34+ __dirname ,
35+ 'node_modules/@emotion/react'
36+ ) ,
37+ '@emotion/styled' : path . resolve (
38+ __dirname ,
39+ 'node_modules/@emotion/styled'
40+ ) ,
41+ '@emotion/cache' : path . resolve (
42+ __dirname ,
43+ 'node_modules/@emotion/cache'
44+ ) ,
45+ } ,
46+ } ,
47+ optimizeDeps : {
48+ include : [
49+ '@emotion/react' ,
50+ '@emotion/styled' ,
51+ '@emotion/cache' ,
52+ '@mui/material' ,
53+ '@mui/icons-material' ,
54+ '@mui/system' ,
55+ ] ,
56+ force : true ,
57+ } ,
1358 build : {
1459 lib : {
15- entry : resolve ( __dirname , 'src/index.jsx' ) ,
60+ entry : path . resolve ( __dirname , 'src/index.jsx' ) ,
1661 name : 'OpenIMISFeSocialProtection' ,
62+ fileName : ( format ) => `index.${ format === 'es' ? 'es' : 'js' } ` ,
1763 formats : [ 'es' , 'cjs' ] ,
18- fileName : ( format ) => `index.${ format === 'es' ? 'es' : 'js' } `
1964 } ,
20- sourcemap : true ,
21- outDir : 'dist' ,
2265 rollupOptions : {
2366 external : [
2467 'react' ,
2568 'react-dom' ,
69+ 'react/jsx-runtime' ,
70+ 'react/jsx-dev-runtime' ,
2671 'redux' ,
2772 'redux-api-middleware' ,
2873 'react-redux' ,
@@ -38,39 +83,40 @@ export default defineConfig({
3883 'react-router' ,
3984 'react-router-dom' ,
4085 'history' ,
41- '@material-ui/core' ,
42- '@material-ui/icons' ,
86+ '@emotion/react' ,
87+ '@emotion/styled' ,
88+ '@emotion/cache' ,
89+ '@mui/material' ,
90+ '@mui/icons-material' ,
91+ '@mui/system' ,
92+ '@mui/styles' ,
4393 '@material-ui/lab' ,
4494 '@material-ui/pickers' ,
45- '@material-ui/styles' ,
4695 '@date-io/core' ,
4796 '@date-io/moment' ,
4897 'flat' ,
49- / ^ @ m a t e r i a l - u i \/ i c o n s \/ .* / ,
50- / ^ @ m a t e r i a l - u i \/ c o r e \/ .* / ,
51- / ^ @ m a t e r i a l - u i \/ l a b \/ .* / ,
52- / ^ @ b a b e l - .* / ,
53- / ^ @ o p e n i m i s .* /
98+ / ^ @ b a b e l .* / ,
99+ / ^ @ d a t e - i o \/ .* / ,
100+ / ^ @ m a t e r i a l - u i \/ .* / ,
101+ / ^ @ o p e n i m i s .* / ,
54102 ] ,
55103 output : {
56104 globals : {
57- 'react' : 'React' ,
58- 'react-dom' : 'ReactDOM'
59- }
60- }
61- }
62- } ,
63- resolve : {
64- alias : {
65- '@' : resolve ( __dirname , 'src' )
66- }
105+ react : 'React' ,
106+ 'react-dom' : 'ReactDOM' ,
107+ 'react/jsx-runtime' : 'jsxRuntime' ,
108+ 'react/jsx-dev-runtime' : 'jsxDevRuntime' ,
109+ '@emotion/react' : 'EmotionReact' ,
110+ '@emotion/styled' : 'EmotionStyled' ,
111+ '@mui/material' : 'MuiMaterial' ,
112+ } ,
113+ } ,
114+ } ,
115+ sourcemap : true ,
116+ outDir : 'dist' ,
117+ emptyOutDir : true ,
67118 } ,
68- optimizeDeps : {
69- exclude : [
70- 'react' ,
71- 'react-dom' ,
72- 'react/jsx-dev-runtime' ,
73- 'react/jsx-runtime' ,
74- ] ,
119+ ssr : {
120+ noExternal,
75121 } ,
76- } )
122+ } ) ;
0 commit comments