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 147e644
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"homepage": "https://github.com/Opentrons/opentrons#readme",
"peerDependencies": {
"react": "18.2.0",
"react-dom": "18.2.0"
"react-dom": "18.2.0",
"styled-components": "5.3.6"
},
"dependencies": {
"@opentrons/shared-data": "link:../shared-data",
Expand Down
7 changes: 5 additions & 2 deletions components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"composite": true,
"rootDir": "src",
"outDir": "lib",
"declarationDir": "lib",
"noEmit": false,
"jsx": "preserve"
},
"include": ["typings", "src"],
"exclude": ["**/*.stories.tsx"]
}
"exclude": ["**/*.stories.tsx", "dist"]
}
25 changes: 19 additions & 6 deletions components/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ 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,
emptyOutDir: false, // Keep the outDir to avoid removing TS types
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'],
fileName: (format) => (format === 'es' ? 'index.mjs' : 'index.cjs'),
},
rollupOptions: {
external: ['react', 'react-dom', 'styled-components'], // Avoid bundling dependencies
output: {
assetFileNames: '[name].[ext]', // Ensure asset names are kept clean
entryFileNames: '[name].js', // Ensure only compiled JS is output
},
},
commonjsOptions: {
transformMixedEsModules: true,
esmExternals: true,
Expand All @@ -23,7 +33,6 @@ export default defineConfig({
react({
include: '**/*.tsx',
babel: {
// Use babel.config.js files
configFile: true,
},
}),
Expand All @@ -32,6 +41,7 @@ export default defineConfig({
esbuildOptions: {
target: 'es2020',
},
exclude: ['styled-components'],
},
css: {
postcss: {
Expand All @@ -45,8 +55,11 @@ export default defineConfig({
},
},
define: {
'process.env': process.env,
global: 'globalThis',
'process.env': {
NODE_ENV: process.env.NODE_ENV,
OPENTRONS_PROJECT: process.env.OPENTRONS_PROJECT,
},
global: 'globalThis', // Ensure compatibility with global variables
},
resolve: {
alias: {
Expand Down

0 comments on commit 147e644

Please sign in to comment.