Skip to content

Commit 46dff4c

Browse files
committed
add Cloudflare config
1 parent 2f16d5a commit 46dff4c

File tree

9 files changed

+124
-52
lines changed

9 files changed

+124
-52
lines changed

apps/website/.eslintignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
**/*.log
2+
**/.DS_Store
3+
*.
4+
.vscode/settings.json
5+
.history
6+
.yarn
7+
bazel-*
8+
bazel-bin
9+
bazel-out
10+
bazel-qwik
11+
bazel-testlogs
12+
dist
13+
dist-dev
14+
lib
15+
lib-types
16+
etc
17+
external
18+
node_modules
19+
temp
20+
tsc-out
21+
tsdoc-metadata.json
22+
target
23+
output
24+
rollup.config.js
25+
build
26+
.cache
27+
.vscode
28+
.rollup.cache
29+
dist
30+
tsconfig.tsbuildinfo
31+
vite.config.ts

apps/website/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"parser": "@typescript-eslint/parser",
99
"parserOptions": {
10-
"project": ["packages/website/tsconfig.*?.json"],
10+
"project": ["apps/website/tsconfig.*?.json"],
1111
"ecmaVersion": 2021,
1212
"sourceType": "module",
1313
"ecmaFeatures": {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite';
2+
import { extendConfig } from '@builder.io/qwik-city/vite';
3+
import baseConfig from '../../vite.config';
4+
5+
export default extendConfig(baseConfig, () => {
6+
return {
7+
build: {
8+
ssr: true,
9+
rollupOptions: {
10+
input: [
11+
'apps/website/src/entry.cloudflare-pages.tsx',
12+
'@qwik-city-plan',
13+
],
14+
},
15+
},
16+
plugins: [cloudflarePagesAdapter()],
17+
};
18+
});

apps/website/project.json

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,69 @@
22
"name": "website",
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"projectType": "application",
5-
"sourceRoot": "packages/website/src",
5+
"sourceRoot": "apps/website/src",
66
"targets": {
77
"build": {
88
"executor": "qwik-nx:build",
99
"options": {
1010
"runSequence": ["website:build.client", "website:build.ssr"],
11-
"outputPath": "dist/packages/website"
11+
"outputPath": "dist/apps/website"
1212
},
1313
"configurations": {
14-
"preview": {}
15-
}
16-
},
17-
"build.client": {
18-
"executor": "@nrwl/vite:build",
19-
"options": {
20-
"outputPath": "dist/packages/website",
21-
"configFile": "apps/website/vite.config.ts"
22-
}
23-
},
24-
"build.ssr": {
25-
"executor": "@nrwl/vite:build",
26-
"defaultConfiguration": "preview",
27-
"options": {
28-
"outputPath": "dist/packages/website"
29-
},
30-
"configurations": {
31-
"preview": {
32-
"ssr": "src/entry.preview.tsx",
33-
"mode": "production"
34-
}
14+
"preview": {},
15+
"production": {}
3516
}
3617
},
3718
"preview": {
38-
"executor": "@nrwl/vite:preview-server",
19+
"executor": "@nx/vite:preview-server",
3920
"options": {
4021
"buildTarget": "website:build"
4122
}
4223
},
4324
"test": {
44-
"executor": "@nrwl/vite:test",
45-
"outputs": ["../../coverage/packages/website"],
25+
"executor": "@nx/vite:test",
26+
"outputs": ["../../coverage/apps/website"],
4627
"options": {
4728
"passWithNoTests": true,
48-
"reportsDirectory": "../../coverage/packages/website"
29+
"reportsDirectory": "../../coverage/apps/website"
4930
}
5031
},
5132
"serve": {
52-
"executor": "@nrwl/vite:dev-server",
33+
"executor": "@nx/vite:dev-server",
5334
"options": {
5435
"buildTarget": "website:build.client",
5536
"mode": "ssr"
5637
}
5738
},
58-
"serve.debug": {
59-
"executor": "nx:run-commands",
39+
"build.client": {
40+
"executor": "@nx/vite:build",
6041
"options": {
61-
"command": "node --inspect-brk ../../node_modules/vite/bin/vite.js --mode ssr --force",
62-
"cwd": "packages/website"
42+
"outputPath": "dist/apps/website",
43+
"configFile": "apps/website/vite.config.ts"
6344
}
6445
},
65-
"lint": {
66-
"executor": "@nrwl/linter:eslint",
67-
"outputs": ["{options.outputFile}"],
46+
"build.ssr": {
47+
"executor": "@nx/vite:build",
48+
"defaultConfiguration": "preview",
49+
"options": {
50+
"outputPath": "dist/apps/website"
51+
},
52+
"configurations": {
53+
"preview": {
54+
"ssr": "src/entry.preview.tsx",
55+
"mode": "production"
56+
},
57+
"production": {
58+
"configFile": "apps/website/adapters/cloudflare-pages/vite.config.ts"
59+
}
60+
},
61+
"dependsOn": []
62+
},
63+
"serve.debug": {
64+
"executor": "nx:run-commands",
6865
"options": {
69-
"lintFilePatterns": ["packages/website/**/*.{ts,tsx,js,jsx}"]
66+
"command": "node --inspect-brk ../..//node_modules/vite/bin/vite.js --mode ssr --force",
67+
"cwd": "apps/website"
7068
}
7169
},
7270
"deploy": {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* WHAT IS THIS FILE?
3+
*
4+
* It's the entry point for cloudflare-pages when building for production.
5+
*
6+
* Learn more about the cloudflare integration here:
7+
* - https://qwik.builder.io/integrations/deployments/cloudflare-pages/
8+
*
9+
*/
10+
import {
11+
createQwikCity,
12+
type PlatformCloudflarePages,
13+
} from '@builder.io/qwik-city/middleware/cloudflare-pages';
14+
import qwikCityPlan from '@qwik-city-plan';
15+
import { manifest } from '@qwik-client-manifest';
16+
import render from './entry.ssr';
17+
18+
declare global {
19+
interface QwikCityPlatform extends PlatformCloudflarePages {}
20+
}
21+
22+
const fetch = createQwikCity({ render, qwikCityPlan, manifest });
23+
24+
export { fetch };

apps/website/src/entry.ssr.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
* - npm run build
1111
*
1212
*/
13-
import { renderToStream, RenderToStreamOptions } from '@builder.io/qwik/server';
13+
import {
14+
renderToStream,
15+
type RenderToStreamOptions,
16+
} from '@builder.io/qwik/server';
1417
import { manifest } from '@qwik-client-manifest';
1518
import Root from './root';
1619

apps/website/src/routes/docs/index.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/website/src/routes/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import type { RequestHandler } from '@builder.io/qwik-city';
1+
import { component$ } from '@builder.io/qwik';
2+
import type { DocumentHead } from '@builder.io/qwik-city';
23

3-
export const onRequest: RequestHandler = async ({ redirect }) => {
4-
throw redirect(308, '/docs/');
4+
export default component$(() => {
5+
return <h1>DOCS: Qwik Storefront UI </h1>;
6+
});
7+
8+
export const head: DocumentHead = {
9+
title: 'Qwik Storefront UI',
510
};

apps/website/vite.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { qwikCity } from '@builder.io/qwik-city/vite';
21
import { qwikVite } from '@builder.io/qwik/optimizer';
3-
import { qwikNxVite } from 'qwik-nx/plugins';
2+
import { qwikCity } from '@builder.io/qwik-city/vite';
43
import { defineConfig } from 'vite';
54
import tsconfigPaths from 'vite-tsconfig-paths';
5+
import { qwikNxVite } from 'qwik-nx/plugins';
66

77
export default defineConfig({
88
plugins: [
99
qwikNxVite(),
1010
qwikCity(),
1111
qwikVite({
1212
client: {
13-
outDir: '../../dist/packages/website/client',
13+
outDir: '../../dist/apps/website/client',
1414
},
1515
ssr: {
16-
outDir: '../../dist/packages/website/server',
16+
outDir: '../../dist/apps/website/server',
1717
},
1818
}),
1919
tsconfigPaths({ root: '../../' }),

0 commit comments

Comments
 (0)