Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Mar 10, 2025
1 parent f797d20 commit ddecaff
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 22 deletions.
3 changes: 2 additions & 1 deletion fixtures/webstudio-cloudflare-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@types/react-dom": "^18.2.25",
"typescript": "5.7.3",
"vite": "^5.4.11",
"wrangler": "^3.63.2"
"wrangler": "^3.63.2",
"fast-glob": "^3.3.2"
}
}
27 changes: 27 additions & 0 deletions fixtures/webstudio-cloudflare-template/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,34 @@ import {
} from "@remix-run/dev";
import { defineConfig } from "vite";

import { existsSync } from "node:fs";
// @ts-ignore
import path from "node:path";
// @ts-ignore
import fg from "fast-glob";

const rootDir = ["..", "../..", "../../.."]
.map((dir) => path.join(__dirname, dir))
.find((dir) => existsSync(path.join(dir, ".git")));

const hasPrivateFolders =
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
ignore: ["**/node_modules/**"],
}).length > 0;

const conditions = hasPrivateFolders
? ["webstudio-private", "webstudio"]
: ["webstudio"];

export default defineConfig(({ mode }) => ({
resolve: {
conditions,
},
ssr: {
resolve: {
conditions,
},
},
plugins: [
// without this, remixCloudflareDevProxy trying to load workerd even for production (it's not needed for production)
mode === "production" ? undefined : remixCloudflareDevProxy(),
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"@webstudio-is/sdk-components-react-remix": "workspace:*",
"@webstudio-is/sdk-components-react-router": "workspace:*",
"@webstudio-is/tsconfig": "workspace:*",
"fast-glob": "^3.3.2",
"h3": "^1.15.1",
"ipx": "^3.0.1",
"prettier": "3.4.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/templates/saas-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"dependencies": {
"worktop": "0.8.0-next.18",
"zod": "^3.22.4"
},
"devDependencies": {
"fast-glob": "^3.3.2"
}
}
48 changes: 48 additions & 0 deletions packages/cli/templates/saas-helpers/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
vitePlugin as remix,
cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
} from "@remix-run/dev";
import { defineConfig } from "vite";

import { existsSync } from "node:fs";
// @ts-ignore
import path from "node:path";
// @ts-ignore
import fg from "fast-glob";

const rootDir = ["..", "../..", "../../.."]
.map((dir) => path.join(__dirname, dir))
.find((dir) => existsSync(path.join(dir, ".git")));

const hasPrivateFolders =
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
ignore: ["**/node_modules/**"],
}).length > 0;

const conditions = hasPrivateFolders
? ["webstudio-private", "webstudio"]
: ["webstudio"];

export default defineConfig(({ mode }) => ({
resolve: {
conditions,
},
ssr: {
resolve: {
conditions,
},
},
plugins: [
// without this, remixCloudflareDevProxy trying to load workerd even for production (it's not needed for production)
mode === "production" ? undefined : remixCloudflareDevProxy(),
remix({
future: {
v3_lazyRouteDiscovery: false,
v3_relativeSplatPath: false,
v3_singleFetch: false,
v3_fetcherPersist: false,
v3_throwAbortReason: false,
},
}),
].filter(Boolean),
}));
17 changes: 0 additions & 17 deletions packages/cli/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import { defineConfig } from "vite";
import fg from "fast-glob";
import pkg from "./package.json";
import { existsSync } from "node:fs";
import path from "node:path";

const rootDir = ["..", "../..", "../../.."]
.map((dir) => path.join(__dirname, dir))
.find((dir) => existsSync(path.join(dir, ".git")));

const hasPrivateFolders =
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
ignore: ["**/node_modules/**"],
}).length > 0;

const isExternal = (id: string, importer: string | undefined) => {
if (id.startsWith("@webstudio-is/")) {
Expand Down Expand Up @@ -43,11 +31,6 @@ const isExternal = (id: string, importer: string | undefined) => {

export default defineConfig({
// resolve only webstudio condition in tests
resolve: {
conditions: hasPrivateFolders
? ["webstudio-private", "webstudio"]
: ["webstudio"],
},
build: {
minify: false,
lib: {
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit ddecaff

Please sign in to comment.