Skip to content

Commit

Permalink
Try to build sdk-components-react with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Nov 13, 2024
1 parent 9798395 commit ea40d76
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/sdk-components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
},
"scripts": {
"build": "rm -rf lib && esbuild src/components.ts src/metas.ts src/props.ts --outdir=lib --bundle --format=esm --packages=external",
"build": "vite build --config ../../vite.sdk-components.config.ts",
"build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts' && prettier --write \"**/*.props.ts\"",
"dts": "tsc --project tsconfig.dts.json",
"test": "vitest run",
Expand Down Expand Up @@ -63,6 +63,7 @@
"react": "18.3.0-canary-14898b6a9-20240318",
"react-dom": "18.3.0-canary-14898b6a9-20240318",
"typescript": "5.6.3",
"vite": "^5.4.10",
"vitest": "^2.1.4"
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vite.sdk-components.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from "vite";

const isBareImport = (id: string) =>
id.startsWith("@") || id.includes(".") === false;

export default defineConfig({
// resolve only webstudio condition in tests
resolve: {
conditions: ["webstudio"],
},
build: {
lib: {
entry: [
"src/components.ts",
"src/metas.ts",
"src/props.ts",
"src/hooks.ts",
],
formats: ["es"],
},
rollupOptions: {
external: isBareImport,
output: {
preserveModules: true,
preserveModulesRoot: "src",
dir: "lib",
},
},
},
});

0 comments on commit ea40d76

Please sign in to comment.