Skip to content

Commit 6f4ecd4

Browse files
ErioldDaniel Montoya
andauthored
fix(): se agrega division de configuracion de vite para documentacion (#705)
Co-authored-by: Daniel Montoya <daniel.montoya@eclass.cl>
1 parent 12a92e9 commit 6f4ecd4

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

vite.config.ts

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

6+
// VITE_REACT_DEPLOY_DOCUMENTATION viene de tu script "deploy"
7+
const isDocs = import.meta.env.VITE_REACT_DEPLOY_DOCUMENTATION === 'DOCUMENTATION'
8+
69
export default defineConfig({
710
plugins: [react(), tsconfigPaths()],
811
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`,
13-
},
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'
12+
// Cuando sea docs, salida por defecto (dist/)
13+
// y no usaremos el modo "lib"
14+
...(isDocs
15+
? {
16+
// build de la web de componentes
17+
outDir: 'dist-docs',
18+
sourcemap: true,
19+
rollupOptions: {
20+
external: [], // empaquetar todo
21+
},
3222
}
33-
}
34-
}
35-
}
23+
: {
24+
// build de la librería
25+
lib: {
26+
entry: path.resolve(__dirname, 'src/index.ts'),
27+
name: '@eclass/ui-kit',
28+
fileName: (format: string) => `eclass-ui-kit.${format}.js`,
29+
},
30+
sourcemap: true,
31+
rollupOptions: {
32+
external: [
33+
'react',
34+
'react-dom',
35+
'@chakra-ui/react',
36+
'@emotion/react',
37+
'@emotion/styled',
38+
'framer-motion',
39+
],
40+
output: {
41+
globals: {
42+
react: 'React',
43+
'react-dom': 'ReactDOM',
44+
'@chakra-ui/react': 'Chakra',
45+
'@emotion/react': 'EmotionReact',
46+
'@emotion/styled': 'EmotionStyled',
47+
'framer-motion': 'framerMotion',
48+
},
49+
},
50+
},
51+
}),
52+
},
3653
})

0 commit comments

Comments
 (0)