Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shlokamin committed Nov 13, 2024
1 parent ad0de84 commit fe5c65c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import lostCss from 'lost'
export default defineConfig({
build: {
// Relative to the root
ssr: 'src/index.ts',
outDir: 'lib',
// do not delete the outdir, typescript types might live there and we dont want to delete them
emptyOutDir: false,
commonjsOptions: {
transformMixedEsModules: true,
esmExternals: true,
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'], // Generate both ES Module and CommonJS outputs
fileName: (format) => (format === 'es' ? 'index.mjs' : 'index.cjs'),
},
rollupOptions: {
external: ['react', 'react-dom', 'styled-components'], // Ensure peer dependencies are not bundled
},
target: 'es2017', // Transpile down to a compatible version for Next.js (for Protocol Library)
},
plugins: [
react({
Expand All @@ -32,6 +36,7 @@ export default defineConfig({
esbuildOptions: {
target: 'es2020',
},
exclude: ['styled-components'], // Avoid pre-bundling styled-components
},
css: {
postcss: {
Expand All @@ -55,5 +60,6 @@ export default defineConfig({
'../components/src/index.module.css'
),
},
dedupe: ['styled-components'], // Prevent duplicate styled-components instances
},
})

0 comments on commit fe5c65c

Please sign in to comment.