Skip to content

Commit 54ddbdc

Browse files
committed
Add ability to play localy
1 parent 33db65c commit 54ddbdc

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

fixtures/webstudio-features/.template/vite.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,35 @@ import { defineConfig } from "vite";
33
import { reactRouter } from "@react-router/dev/vite";
44
// @ts-ignore
55
import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
6+
import { existsSync, readdirSync } from "fs";
7+
// @ts-ignore
8+
import path from "path";
9+
10+
const isFolderEmpty = (folderPath: string) => {
11+
if (!existsSync(folderPath)) {
12+
return true; // Folder does not exist
13+
}
14+
const contents = readdirSync(folderPath);
15+
16+
return contents.length === 0;
17+
};
18+
19+
const hasPrivateFolders = !isFolderEmpty(
20+
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
21+
);
22+
23+
const conditions = hasPrivateFolders
24+
? ["webstudio-private", "webstudio"]
25+
: ["webstudio"];
626

727
export default defineConfig({
28+
resolve: {
29+
conditions,
30+
},
31+
ssr: {
32+
resolve: {
33+
conditions,
34+
},
35+
},
836
plugins: [reactRouter(), dedupeMeta],
937
});

fixtures/webstudio-features/vite.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,35 @@ import { defineConfig } from "vite";
33
import { reactRouter } from "@react-router/dev/vite";
44
// @ts-ignore
55
import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
6+
import { existsSync, readdirSync } from "fs";
7+
// @ts-ignore
8+
import path from "path";
9+
10+
const isFolderEmpty = (folderPath: string) => {
11+
if (!existsSync(folderPath)) {
12+
return true; // Folder does not exist
13+
}
14+
const contents = readdirSync(folderPath);
15+
16+
return contents.length === 0;
17+
};
18+
19+
const hasPrivateFolders = !isFolderEmpty(
20+
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
21+
);
22+
23+
const conditions = hasPrivateFolders
24+
? ["webstudio-private", "webstudio"]
25+
: ["webstudio"];
626

727
export default defineConfig({
28+
resolve: {
29+
conditions,
30+
},
31+
ssr: {
32+
resolve: {
33+
conditions,
34+
},
35+
},
836
plugins: [reactRouter(), dedupeMeta],
937
});

0 commit comments

Comments
 (0)