Skip to content

Commit bc3e083

Browse files
ErioldDaniel Montoya
andauthored
fix(): se hace reduccin del bundle probando la configuracion sugerida (#704)
Co-authored-by: Daniel Montoya <daniel.montoya@eclass.cl>
1 parent fb28aad commit bc3e083

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
},
5151
"peerDependencies": {
5252
"react": "^16.8 || 17.x || ^18.0.0 || ^19.0.0",
53-
"react-dom": "^16.8 || 17.x || ^18.0.0 || ^19.0.0"
53+
"react-dom": "^16.8 || 17.x || ^18.0.0 || ^19.0.0",
54+
"@chakra-ui/react": "^1.8.9",
55+
"@emotion/react": "^11.8.2",
56+
"@emotion/styled": "^11.8.1",
57+
"framer-motion": "^6.2.8"
5458
},
5559
"devDependencies": {
5660
"@commitlint/cli": "13.2.1",
@@ -127,5 +131,6 @@
127131
"resolutions": {
128132
"@types/react": "17.0.2",
129133
"@types/react-dom": "17.0.2"
130-
}
134+
},
135+
"sideEffects": false
131136
}

vite.config.ts

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,34 @@ import react from '@vitejs/plugin-react'
33
import tsconfigPaths from 'vite-tsconfig-paths'
44
import path from 'path'
55

6-
// https://vitejs.dev/config/
7-
8-
let myDefineConfig
9-
10-
const buildEnv = process.env.VITE_REACT_DEPLOY_DOCUMENTATION
11-
12-
if (buildEnv === 'DOCUMENTATION') {
13-
myDefineConfig = {
14-
plugins: [react(), tsconfigPaths()],
15-
build: {
16-
sourcemap: true,
6+
export default defineConfig({
7+
plugins: [react(), tsconfigPaths()],
8+
build: {
9+
lib: {
10+
entry: path.resolve(__dirname, 'src/index.ts'),
11+
name: '@eclass/ui-kit',
12+
fileName: (format: string) => `eclass-ui-kit.${format}.js`,
1713
},
14+
sourcemap: true,
15+
rollupOptions: {
16+
external: [
17+
'react',
18+
'react-dom',
19+
'@chakra-ui/react',
20+
'@emotion/react',
21+
'@emotion/styled',
22+
'framer-motion'
23+
],
24+
output: {
25+
globals: {
26+
react: 'React',
27+
'react-dom': 'ReactDOM',
28+
'@chakra-ui/react': 'Chakra',
29+
'@emotion/react': 'EmotionReact',
30+
'@emotion/styled': 'EmotionStyled',
31+
'framer-motion': 'framerMotion'
32+
}
33+
}
34+
}
1835
}
19-
} else {
20-
myDefineConfig = {
21-
plugins: [react(), tsconfigPaths()],
22-
build: {
23-
lib: {
24-
entry: path.resolve(__dirname, 'src/index.ts'),
25-
name: '@eclass/ui-kit',
26-
fileName: (format: string) => `eclass-ui-kit.${format}.js`,
27-
},
28-
sourcemap: true,
29-
rollupOptions: {
30-
// make sure to externalize deps that shouldn't be bundled
31-
// into your library
32-
external: ['react'],
33-
output: {
34-
// Provide global variables to use in the UMD build
35-
// for externalized deps
36-
globals: {
37-
react: 'React',
38-
},
39-
},
40-
},
41-
},
42-
}
43-
}
44-
45-
export default defineConfig(myDefineConfig)
36+
})

0 commit comments

Comments
 (0)