webstudio 0.0.0-017f1bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +139 -0
- package/bin.js +5 -0
- package/lib/cli.js +9121 -0
- package/package.json +90 -0
- package/templates/cloudflare/WS_CF_README.md +48 -0
- package/templates/cloudflare/functions/[[path]].ts +9 -0
- package/templates/cloudflare/load-context.ts +9 -0
- package/templates/cloudflare/package.json +22 -0
- package/templates/cloudflare/tsconfig.json +18 -0
- package/templates/cloudflare/vite.config.ts +29 -0
- package/templates/cloudflare/worker-configuration.d.ts +3 -0
- package/templates/cloudflare/wrangler.toml +55 -0
- package/templates/defaults/app/constants.mjs +12 -0
- package/templates/defaults/app/extension.ts +16 -0
- package/templates/defaults/app/root.tsx +39 -0
- package/templates/defaults/app/route-templates/default-sitemap.tsx +34 -0
- package/templates/defaults/app/route-templates/html.tsx +296 -0
- package/templates/defaults/app/route-templates/redirect.tsx +6 -0
- package/templates/defaults/app/route-templates/xml.tsx +83 -0
- package/templates/defaults/app/routes/[robots.txt].tsx +24 -0
- package/templates/defaults/package.json +35 -0
- package/templates/defaults/public/favicon.ico +0 -0
- package/templates/defaults/tsconfig.json +22 -0
- package/templates/defaults/vite.config.ts +24 -0
- package/templates/internal/package.json +11 -0
- package/templates/internal/tsconfig.json +5 -0
- package/templates/react-router/app/extension.ts +13 -0
- package/templates/react-router/app/root.tsx +39 -0
- package/templates/react-router/app/route-templates/default-sitemap.tsx +34 -0
- package/templates/react-router/app/route-templates/html.tsx +294 -0
- package/templates/react-router/app/route-templates/redirect.tsx +6 -0
- package/templates/react-router/app/route-templates/xml.tsx +87 -0
- package/templates/react-router/app/routes/[robots.txt].tsx +24 -0
- package/templates/react-router/app/routes.ts +4 -0
- package/templates/react-router/package.json +34 -0
- package/templates/react-router/public/favicon.ico +0 -0
- package/templates/react-router/tsconfig.json +18 -0
- package/templates/react-router/vite.config.ts +14 -0
- package/templates/react-router-cloudflare/app/constants.mjs +21 -0
- package/templates/react-router-cloudflare/app/entry.server.tsx +43 -0
- package/templates/react-router-cloudflare/package.json +12 -0
- package/templates/react-router-cloudflare/react-router.config.ts +7 -0
- package/templates/react-router-cloudflare/tsconfig.json +23 -0
- package/templates/react-router-cloudflare/vite.config.ts +15 -0
- package/templates/react-router-cloudflare/workers/app.ts +26 -0
- package/templates/react-router-cloudflare/wrangler.jsonc +6 -0
- package/templates/react-router-docker/.dockerignore +4 -0
- package/templates/react-router-docker/Dockerfile +19 -0
- package/templates/react-router-docker/app/constants.mjs +31 -0
- package/templates/react-router-docker/app/routes/[_image].$.ts +24 -0
- package/templates/react-router-docker/package.json +11 -0
- package/templates/react-router-netlify/app/constants.mjs +29 -0
- package/templates/react-router-netlify/netlify.toml +6 -0
- package/templates/react-router-netlify/package.json +10 -0
- package/templates/react-router-netlify/vite.config.ts +15 -0
- package/templates/react-router-vercel/app/constants.mjs +25 -0
- package/templates/react-router-vercel/package.json +9 -0
- package/templates/react-router-vercel/react-router.config.ts +6 -0
- package/templates/react-router-vercel/vercel.json +12 -0
- package/templates/saas-helpers/package.json +9 -0
- package/templates/saas-helpers/tsconfig.json +18 -0
- package/templates/saas-helpers/vite.config.ts +48 -0
- package/templates/ssg/app/constants.mjs +13 -0
- package/templates/ssg/app/route-templates/html/+Head.tsx +100 -0
- package/templates/ssg/app/route-templates/html/+Page.tsx +23 -0
- package/templates/ssg/app/route-templates/html/+data.ts +37 -0
- package/templates/ssg/package.json +31 -0
- package/templates/ssg/pages/+config.ts +12 -0
- package/templates/ssg/public/favicon.ico +0 -0
- package/templates/ssg/renderer/+onRenderClient.tsx +30 -0
- package/templates/ssg/renderer/+onRenderHtml.tsx +37 -0
- package/templates/ssg/tsconfig.json +22 -0
- package/templates/ssg/vike.d.ts +25 -0
- package/templates/ssg/vite.config.ts +15 -0
- package/templates/ssg-netlify/app/constants.mjs +30 -0
- package/templates/ssg-vercel/app/constants.mjs +26 -0
- package/templates/ssg-vercel/public/vercel.json +11 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LoaderFunctionArgs } from "react-router";
|
|
2
|
+
|
|
3
|
+
export const loader = (arg: LoaderFunctionArgs) => {
|
|
4
|
+
const host =
|
|
5
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
6
|
+
arg.request.headers.get("host") ||
|
|
7
|
+
"";
|
|
8
|
+
|
|
9
|
+
return new Response(
|
|
10
|
+
`
|
|
11
|
+
User-agent: *
|
|
12
|
+
Disallow: /api/
|
|
13
|
+
|
|
14
|
+
Sitemap: https://${host}/sitemap.xml
|
|
15
|
+
|
|
16
|
+
`,
|
|
17
|
+
{
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "text/plain",
|
|
20
|
+
},
|
|
21
|
+
status: 200,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"private": true,
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "react-router build",
|
|
7
|
+
"dev": "react-router dev",
|
|
8
|
+
"typecheck": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@react-router/dev": "^7.5.3",
|
|
12
|
+
"@react-router/fs-routes": "^7.5.3",
|
|
13
|
+
"@webstudio-is/image": "0.0.0-017f1bd",
|
|
14
|
+
"@webstudio-is/react-sdk": "0.0.0-017f1bd",
|
|
15
|
+
"@webstudio-is/sdk": "0.0.0-017f1bd",
|
|
16
|
+
"@webstudio-is/sdk-components-animation": "0.0.0-017f1bd",
|
|
17
|
+
"@webstudio-is/sdk-components-react-radix": "0.0.0-017f1bd",
|
|
18
|
+
"@webstudio-is/sdk-components-react-router": "0.0.0-017f1bd",
|
|
19
|
+
"@webstudio-is/sdk-components-react": "0.0.0-017f1bd",
|
|
20
|
+
"isbot": "^5.1.25",
|
|
21
|
+
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
22
|
+
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
23
|
+
"react-router": "^7.5.3",
|
|
24
|
+
"vite": "^6.3.4"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^18.2.70",
|
|
28
|
+
"@types/react-dom": "^18.2.25",
|
|
29
|
+
"typescript": "5.8.2"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
+
"types": ["vite/client", "@webstudio-is/react-sdk/placeholder"],
|
|
6
|
+
"isolatedModules": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"target": "ES2022",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"skipLibCheck": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [reactRouter()],
|
|
6
|
+
resolve: {
|
|
7
|
+
conditions: ["browser", "development|production"],
|
|
8
|
+
},
|
|
9
|
+
ssr: {
|
|
10
|
+
resolve: {
|
|
11
|
+
conditions: ["node", "development|production"],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
9
|
+
*/
|
|
10
|
+
export const imageLoader = (props) => {
|
|
11
|
+
if (import.meta.env.DEV) {
|
|
12
|
+
return props.src;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (props.format === "raw") {
|
|
16
|
+
return props.src;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// @todo https://developers.cloudflare.com/images/transform-images/transform-via-url/
|
|
20
|
+
return props.src;
|
|
21
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AppLoadContext, EntryContext } from "react-router";
|
|
2
|
+
import { ServerRouter } from "react-router";
|
|
3
|
+
import { isbot } from "isbot";
|
|
4
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
export default async function handleRequest(
|
|
7
|
+
request: Request,
|
|
8
|
+
responseStatusCode: number,
|
|
9
|
+
responseHeaders: Headers,
|
|
10
|
+
routerContext: EntryContext,
|
|
11
|
+
_loadContext: AppLoadContext
|
|
12
|
+
) {
|
|
13
|
+
let shellRendered = false;
|
|
14
|
+
const userAgent = request.headers.get("user-agent");
|
|
15
|
+
|
|
16
|
+
const body = await renderToReadableStream(
|
|
17
|
+
<ServerRouter context={routerContext} url={request.url} />,
|
|
18
|
+
{
|
|
19
|
+
onError(error: unknown) {
|
|
20
|
+
responseStatusCode = 500;
|
|
21
|
+
// Log streaming rendering errors from inside the shell. Don't log
|
|
22
|
+
// errors encountered during initial shell rendering since they'll
|
|
23
|
+
// reject and get logged in handleDocumentRequest.
|
|
24
|
+
if (shellRendered) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
shellRendered = true;
|
|
31
|
+
|
|
32
|
+
// Ensure requests from bots and SPA Mode renders wait for all content to load before responding
|
|
33
|
+
// https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
|
|
34
|
+
if ((userAgent && isbot(userAgent)) || routerContext.isSpaMode) {
|
|
35
|
+
await body.allReady;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
39
|
+
return new Response(body, {
|
|
40
|
+
headers: responseHeaders,
|
|
41
|
+
status: responseStatusCode,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"typecheck": "wrangler types && tsc",
|
|
4
|
+
"typegen": "wrangler types",
|
|
5
|
+
"preview": "react-router build && vite preview",
|
|
6
|
+
"deploy": "react-router build && wrangler deploy"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@cloudflare/vite-plugin": "^1.1.0",
|
|
10
|
+
"wrangler": "^4.14.1"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
+
"types": [
|
|
6
|
+
"./worker-configuration.d.ts",
|
|
7
|
+
"vite/client",
|
|
8
|
+
"@webstudio-is/react-sdk/placeholder"
|
|
9
|
+
],
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"target": "ES2022",
|
|
16
|
+
"strict": true,
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"customConditions": ["webstudio"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
3
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [cloudflare({ viteEnvironment: { name: "ssr" } }), reactRouter()],
|
|
7
|
+
resolve: {
|
|
8
|
+
conditions: ["browser", "development|production"],
|
|
9
|
+
},
|
|
10
|
+
ssr: {
|
|
11
|
+
resolve: {
|
|
12
|
+
conditions: ["node", "development|production"],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequestHandler } from "react-router";
|
|
2
|
+
|
|
3
|
+
declare module "react-router" {
|
|
4
|
+
export interface AppLoadContext {
|
|
5
|
+
cloudflare: {
|
|
6
|
+
env: Env;
|
|
7
|
+
ctx: ExecutionContext;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const requestHandler = createRequestHandler(
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
() => import("virtual:react-router/server-build"),
|
|
15
|
+
import.meta.env.MODE
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
async fetch(request, env, ctx) {
|
|
20
|
+
return requestHandler(request, {
|
|
21
|
+
EXCLUDE_FROM_SEARCH: false,
|
|
22
|
+
getDefaultActionResource: undefined,
|
|
23
|
+
cloudflare: { env, ctx },
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
} satisfies ExportedHandler<Env>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
FROM node:22-alpine AS dependencies-env
|
|
2
|
+
COPY .npmrc package.json /app/
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
RUN npm install --omit=dev
|
|
5
|
+
|
|
6
|
+
FROM dependencies-env AS build-env
|
|
7
|
+
COPY . /app/
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
RUN npm install
|
|
10
|
+
RUN npm run build
|
|
11
|
+
|
|
12
|
+
FROM node:22-alpine
|
|
13
|
+
COPY .npmrc package.json /app/
|
|
14
|
+
COPY --from=dependencies-env /app/node_modules /app/node_modules
|
|
15
|
+
COPY --from=build-env /app/build /app/build
|
|
16
|
+
COPY --from=build-env /app/public /app/public
|
|
17
|
+
WORKDIR /app
|
|
18
|
+
# there is a DOMAINS env with comma separated allowed domains for image processing
|
|
19
|
+
CMD ["npm", "run", "start"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* URL.canParse(props.src)
|
|
9
|
+
* @type {(url: string) => boolean}
|
|
10
|
+
*/
|
|
11
|
+
const UrlCanParse = (url) => {
|
|
12
|
+
try {
|
|
13
|
+
new URL(url);
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
22
|
+
*/
|
|
23
|
+
export const imageLoader = (props) => {
|
|
24
|
+
if (props.format === "raw") {
|
|
25
|
+
return props.src;
|
|
26
|
+
}
|
|
27
|
+
// handle absolute urls
|
|
28
|
+
const path = UrlCanParse(props.src) ? `/${props.src}` : props.src;
|
|
29
|
+
// https://github.com/unjs/ipx?tab=readme-ov-file#modifiers
|
|
30
|
+
return `/_image/w_${props.width},q_${props.quality}${path}`;
|
|
31
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { env } from "node:process";
|
|
2
|
+
import type { LoaderFunctionArgs } from "react-router";
|
|
3
|
+
import {
|
|
4
|
+
createIPX,
|
|
5
|
+
createIPXH3Handler,
|
|
6
|
+
ipxFSStorage,
|
|
7
|
+
ipxHttpStorage,
|
|
8
|
+
} from "ipx";
|
|
9
|
+
import { createApp, toWebHandler } from "h3";
|
|
10
|
+
|
|
11
|
+
const domains = env.DOMAINS?.split(/\s*,\s*/) ?? [];
|
|
12
|
+
|
|
13
|
+
const ipx = createIPX({
|
|
14
|
+
storage: ipxFSStorage({ dir: "./public" }),
|
|
15
|
+
httpStorage: ipxHttpStorage({ domains }),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const handleRequest = toWebHandler(
|
|
19
|
+
createApp().use("/_image", createIPXH3Handler(ipx))
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const loader = async (args: LoaderFunctionArgs) => {
|
|
23
|
+
return handleRequest(args.request);
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
9
|
+
*/
|
|
10
|
+
export const imageLoader = (props) => {
|
|
11
|
+
if (import.meta.env.DEV) {
|
|
12
|
+
return props.src;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (props.format === "raw") {
|
|
16
|
+
return props.src;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// https://docs.netlify.com/image-cdn/overview/
|
|
20
|
+
const searchParams = new URLSearchParams();
|
|
21
|
+
searchParams.set("url", props.src);
|
|
22
|
+
searchParams.set("w", props.width.toString());
|
|
23
|
+
if (props.height) {
|
|
24
|
+
searchParams.set("h", props.height.toString());
|
|
25
|
+
}
|
|
26
|
+
searchParams.set("q", props.quality.toString());
|
|
27
|
+
// fit=contain by default
|
|
28
|
+
return `/.netlify/images?${searchParams}`;
|
|
29
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import netlifyPlugin from "@netlify/vite-plugin-react-router";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [reactRouter(), netlifyPlugin()],
|
|
7
|
+
resolve: {
|
|
8
|
+
conditions: ["browser", "development|production"],
|
|
9
|
+
},
|
|
10
|
+
ssr: {
|
|
11
|
+
resolve: {
|
|
12
|
+
conditions: ["node", "development|production"],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
9
|
+
*/
|
|
10
|
+
export const imageLoader = (props) => {
|
|
11
|
+
if (import.meta.env.DEV) {
|
|
12
|
+
return props.src;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (props.format === "raw") {
|
|
16
|
+
return props.src;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// https://vercel.com/blog/build-your-own-web-framework#automatic-image-optimization
|
|
20
|
+
const searchParams = new URLSearchParams();
|
|
21
|
+
searchParams.set("url", props.src);
|
|
22
|
+
searchParams.set("w", props.width.toString());
|
|
23
|
+
searchParams.set("q", props.quality.toString());
|
|
24
|
+
return `/_vercel/image?${searchParams}`;
|
|
25
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"**/*.ts",
|
|
4
|
+
"**/*.tsx",
|
|
5
|
+
"**/.server/**/*.ts",
|
|
6
|
+
"**/.server/**/*.tsx",
|
|
7
|
+
"**/.client/**/*.ts",
|
|
8
|
+
"**/.client/**/*.tsx"
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"types": [
|
|
12
|
+
"@remix-run/cloudflare",
|
|
13
|
+
"vite/client",
|
|
14
|
+
"@cloudflare/workers-types/2023-07-01",
|
|
15
|
+
"@webstudio-is/react-sdk/placeholder"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
vitePlugin as remix,
|
|
3
|
+
cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
|
|
4
|
+
} from "@remix-run/dev";
|
|
5
|
+
import { defineConfig } from "vite";
|
|
6
|
+
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
import fg from "fast-glob";
|
|
12
|
+
|
|
13
|
+
const rootDir = ["..", "../..", "../../.."]
|
|
14
|
+
.map((dir) => path.join(__dirname, dir))
|
|
15
|
+
.find((dir) => existsSync(path.join(dir, ".git")));
|
|
16
|
+
|
|
17
|
+
const hasPrivateFolders =
|
|
18
|
+
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
|
|
19
|
+
ignore: ["**/node_modules/**"],
|
|
20
|
+
}).length > 0;
|
|
21
|
+
|
|
22
|
+
const conditions = hasPrivateFolders
|
|
23
|
+
? ["webstudio-private", "webstudio"]
|
|
24
|
+
: ["webstudio"];
|
|
25
|
+
|
|
26
|
+
export default defineConfig(({ mode }) => ({
|
|
27
|
+
resolve: {
|
|
28
|
+
conditions: [...conditions, "browser", "development|production"],
|
|
29
|
+
},
|
|
30
|
+
ssr: {
|
|
31
|
+
resolve: {
|
|
32
|
+
conditions: [...conditions, "node", "development|production"],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
// without this, remixCloudflareDevProxy trying to load workerd even for production (it's not needed for production)
|
|
37
|
+
mode === "production" ? undefined : remixCloudflareDevProxy(),
|
|
38
|
+
remix({
|
|
39
|
+
future: {
|
|
40
|
+
v3_lazyRouteDiscovery: false,
|
|
41
|
+
v3_relativeSplatPath: false,
|
|
42
|
+
v3_singleFetch: false,
|
|
43
|
+
v3_fetcherPersist: false,
|
|
44
|
+
v3_throwAbortReason: false,
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const assetBaseUrl = "/assets/";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
10
|
+
*/
|
|
11
|
+
export const imageLoader = ({ src }) => {
|
|
12
|
+
return src;
|
|
13
|
+
};
|