diff --git a/examples/cloudflare-workers-vue-html-streaming/.test-dev-miniflare.spec.ts b/examples/cloudflare-workers-vue-html-streaming/.test-dev-miniflare.spec.ts
deleted file mode 100644
index 3b3e02ab5b8..00000000000
--- a/examples/cloudflare-workers-vue-html-streaming/.test-dev-miniflare.spec.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { testRun } from '../cloudflare-workers/.testRun'
-testRun('npm run dev:miniflare', { hasStarWarsPage: false })
diff --git a/examples/cloudflare-workers-vue-html-streaming/.test-miniflare.spec.ts b/examples/cloudflare-workers-vue-html-streaming/.test-miniflare.spec.ts
new file mode 100644
index 00000000000..3b2fc5c72a6
--- /dev/null
+++ b/examples/cloudflare-workers-vue-html-streaming/.test-miniflare.spec.ts
@@ -0,0 +1,2 @@
+import { testRun } from '../cloudflare-workers/.testRun'
+testRun('npm run preview:miniflare', { hasStarWarsPage: false })
diff --git a/examples/cloudflare-workers-vue-html-streaming/.test-prod.spec.ts b/examples/cloudflare-workers-vue-html-streaming/.test-prod.spec.ts
deleted file mode 100644
index 6bbcf4d153c..00000000000
--- a/examples/cloudflare-workers-vue-html-streaming/.test-prod.spec.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { testRun } from '../cloudflare-workers/.testRun'
-testRun('npm run prod', { hasStarWarsPage: false })
diff --git a/examples/cloudflare-workers-vue-html-streaming/.test-wrangler.spec.ts b/examples/cloudflare-workers-vue-html-streaming/.test-wrangler.spec.ts
new file mode 100644
index 00000000000..ccd10fb450b
--- /dev/null
+++ b/examples/cloudflare-workers-vue-html-streaming/.test-wrangler.spec.ts
@@ -0,0 +1,2 @@
+import { testRun } from '../cloudflare-workers/.testRun'
+testRun('npm run preview:wrangler', { hasStarWarsPage: false })
diff --git a/examples/cloudflare-workers-vue-html-streaming/package.json b/examples/cloudflare-workers-vue-html-streaming/package.json
index 7cbfa4099cf..30e84e7ba68 100644
--- a/examples/cloudflare-workers-vue-html-streaming/package.json
+++ b/examples/cloudflare-workers-vue-html-streaming/package.json
@@ -1,19 +1,17 @@
{
"scripts": {
- "// For increased dev speed we use an Express.js dev server instead of wrangler": "",
- "dev": "node ./dev-server",
- "// Use miniflare to simulate Cloudflare Workers environment": "",
- "dev:miniflare": "npm run build:vite && miniflare --port 3000 worker/worker/script.js",
- "// Build and try the worker locally": "",
- "prod": "npm run build:vite && wrangler dev --port 3000",
- "// Build and deploy the worker to Cloudflare Workers": "",
+ "// Development server": "",
+ "dev": "node ./devServer",
+ "// Preview worker locally": "",
+ "preview:": "npm run preview:miniflare",
+ "preview:miniflare": "npm run build:vite && miniflare --port 3000 worker/worker/script.js",
+ "preview:wrangler": "npm run build:vite && wrangler dev --port 3000",
+ "// Deploy worker to Cloudflare": "",
"deploy": "npm run build:vite && wrangler publish",
- "// Build scripts": "",
+ "// Build": "",
"build": "npm run build:vite && npm run build:worker",
"build:vite": "vite build && vite build --ssr",
- "build:worker": "wrangler build",
- "// To sustain the vite-plugin-ssr dev link, we need to do this as Wrangler breaks links upon `$ wrangler dev`": "",
- "// postinstall": "(cd ../../vite-plugin-ssr/ && yarn link) && yarn link vite-plugin-ssr"
+ "build:worker": "wrangler build"
},
"dependencies": {
"@cloudflare/kv-asset-handler": "~0.2.0",
diff --git a/examples/cloudflare-workers-vue-html-streaming/readme.md b/examples/cloudflare-workers-vue-html-streaming/readme.md
index e7b0366845b..4702b298e3d 100644
--- a/examples/cloudflare-workers-vue-html-streaming/readme.md
+++ b/examples/cloudflare-workers-vue-html-streaming/readme.md
@@ -10,31 +10,36 @@ Example of deploying to [Cloudflare Workers](https://workers.cloudflare.com/) wi
See [vite-plugin-ssr.com/cloudflare-workers](https://vite-plugin-ssr.com/cloudflare-workers).
-## Run
-
-To run the example:
-1. ```bash
- git clone git@github.com:brillout/vite-plugin-ssr
- cd vite-plugin-ssr/examples/cloudflare-workers-vue-html-streaming/
- ```
-
-2. Create a Cloudflare account and paste your account id in `wrangler.toml#account_id`.
-
-3. ```bash
- npm install
- ```
- To develop (for increased dev speed we use an Express.js dev server instead of `wrangler`):
- ```bash
- npm run dev
- ```
- To build and try the worker locally:
- ```bash
- npm run prod
- ```
- To build and deploy the worker to Cloudflare Workers:
- ```bash
- npm run deploy
- ```
+## Run example
+
+Setup:
+```bash
+git clone git@github.com:brillout/vite-plugin-ssr
+cd vite-plugin-ssr/examples/cloudflare-workers-vue-html-streaming/
+npm install
+```
+
+To develop: (For increased development speed, we use an Express.js development server instead of a worker.)
+```bash
+npm run dev
+```
+
+To try the worker locally with miniflare: (No account needed.)
+```bash
+npm run preview
+```
+
+To be able to use `wrangler`, create a Cloudflare account and paste your account id in `wrangler.toml#account_id`.
+
+To try the worker locally with wrangler:
+```bash
+npm run preview:wrangler
+```
+
+To deploy the worker to Cloudflare:
+```bash
+npm run deploy
+```
## `dist/server/importBuild.js`
diff --git a/examples/cloudflare-workers/.test-dev-miniflare.spec.ts b/examples/cloudflare-workers/.test-dev-miniflare.spec.ts
deleted file mode 100644
index b49350fcc08..00000000000
--- a/examples/cloudflare-workers/.test-dev-miniflare.spec.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { testRun } from './.testRun'
-testRun('npm run dev:miniflare', { hasStarWarsPage: true })
diff --git a/examples/cloudflare-workers/.test-miniflare.spec.ts b/examples/cloudflare-workers/.test-miniflare.spec.ts
new file mode 100644
index 00000000000..4a476e5fe3d
--- /dev/null
+++ b/examples/cloudflare-workers/.test-miniflare.spec.ts
@@ -0,0 +1,2 @@
+import { testRun } from './.testRun'
+testRun('npm run preview:miniflare', { hasStarWarsPage: true })
diff --git a/examples/cloudflare-workers/.test-prod.spec.ts b/examples/cloudflare-workers/.test-prod.spec.ts
deleted file mode 100644
index 3364dab8001..00000000000
--- a/examples/cloudflare-workers/.test-prod.spec.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import { testRun } from './.testRun'
-testRun('npm run prod', { hasStarWarsPage: true })
diff --git a/examples/cloudflare-workers/.test-wrangler.spec.ts b/examples/cloudflare-workers/.test-wrangler.spec.ts
new file mode 100644
index 00000000000..46ff1296df5
--- /dev/null
+++ b/examples/cloudflare-workers/.test-wrangler.spec.ts
@@ -0,0 +1,2 @@
+import { testRun } from './.testRun'
+testRun('npm run preview:wrangler', { hasStarWarsPage: true })
diff --git a/examples/cloudflare-workers/.testRun.ts b/examples/cloudflare-workers/.testRun.ts
index 2001be2daed..100ad7e6511 100644
--- a/examples/cloudflare-workers/.testRun.ts
+++ b/examples/cloudflare-workers/.testRun.ts
@@ -4,11 +4,11 @@ import assert from 'assert'
export { testRun }
function testRun(
- cmd: 'npm run dev' | 'npm run prod' | 'npm run dev:miniflare',
+ cmd: 'npm run dev' | 'npm run preview:miniflare' | 'npm run preview:wrangler',
{ hasStarWarsPage }: { hasStarWarsPage: boolean },
) {
- const isMiniflare = cmd === 'npm run dev:miniflare'
- const isWrangler = cmd === 'npm run prod'
+ const isMiniflare = cmd === 'npm run preview:miniflare'
+ const isWrangler = cmd === 'npm run preview:wrangler'
const isWorker = isMiniflare || isWrangler
if ((isWindows() || isNode12()) && isWorker) {
@@ -16,7 +16,7 @@ function testRun(
return
}
- if (cmd === 'npm run prod') {
+ if (isWrangler) {
if (!isGithubAction() || process.env['GIT_BRANCH'] !== 'master') {
test('SKIPED: wrangler test is not run locally nor in Pull Requests', () => {})
return
diff --git a/examples/cloudflare-workers/package.json b/examples/cloudflare-workers/package.json
index 61b6223f995..95b0ba31092 100644
--- a/examples/cloudflare-workers/package.json
+++ b/examples/cloudflare-workers/package.json
@@ -1,19 +1,17 @@
{
"scripts": {
- "// For increased dev speed we use an Express.js dev server instead of wrangler": "",
- "dev": "node ./dev-server",
- "// Use miniflare to simulate Cloudflare Workers environment": "",
- "dev:miniflare": "npm run build:vite && miniflare --port 3000 worker/worker/script.js",
- "// Build and try the worker locally": "",
- "prod": "npm run build:vite && wrangler dev --port 3000",
- "// Build and deploy the worker to Cloudflare Workers": "",
+ "// Development server": "",
+ "dev": "node ./devServer",
+ "// Preview worker locally": "",
+ "preview:": "npm run preview:miniflare",
+ "preview:miniflare": "npm run build:vite && miniflare --port 3000 worker/worker/script.js",
+ "preview:wrangler": "npm run build:vite && wrangler dev --port 3000",
+ "// Deploy worker to Cloudflare": "",
"deploy": "npm run build:vite && wrangler publish",
- "// Build scripts": "",
+ "// Build": "",
"build": "npm run build:vite && npm run build:worker",
"build:vite": "vite build && vite build --ssr",
- "build:worker": "wrangler build",
- "// To sustain the vite-plugin-ssr dev link, we need to do this as Wrangler breaks links upon `$ wrangler dev`": "",
- "// postinstall": "(cd ../../vite-plugin-ssr/ && yarn link) && yarn link vite-plugin-ssr"
+ "build:worker": "wrangler build"
},
"dependencies": {
"@cloudflare/kv-asset-handler": "~0.2.0",
diff --git a/examples/cloudflare-workers/readme.md b/examples/cloudflare-workers/readme.md
index 1512b04b0d8..09d46e9b743 100644
--- a/examples/cloudflare-workers/readme.md
+++ b/examples/cloudflare-workers/readme.md
@@ -9,32 +9,36 @@ Example of deploying to [Cloudflare Workers](https://workers.cloudflare.com/) wi
See [vite-plugin-ssr.com/cloudflare-workers](https://vite-plugin-ssr.com/cloudflare-workers).
-## Run
-
-To run the example:
-
-1. ```bash
- git clone git@github.com:brillout/vite-plugin-ssr
- cd vite-plugin-ssr/examples/cloudflare-workers/
- ```
-
-2. Create a Cloudflare account and paste your account id in `wrangler.toml#account_id`.
-
-3. ```bash
- npm install
- ```
- To develop (for increased dev speed we use an Express.js dev server instead of `wrangler`):
- ```bash
- npm run dev
- ```
- To build and try the worker locally:
- ```bash
- npm run prod
- ```
- To build and deploy the worker to Cloudflare Workers:
- ```bash
- npm run deploy
- ```
+## Run example
+
+Setup:
+```bash
+git clone git@github.com:brillout/vite-plugin-ssr
+cd vite-plugin-ssr/examples/cloudflare-workers/
+npm install
+```
+
+To develop: (For increased development speed, we use an Express.js development server instead of a worker.)
+```bash
+npm run dev
+```
+
+To try the worker locally with miniflare: (No account needed.)
+```bash
+npm run preview
+```
+
+To be able to use `wrangler`, create a Cloudflare account and paste your account id in `wrangler.toml#account_id`.
+
+To try the worker locally with wrangler:
+```bash
+npm run preview:wrangler
+```
+
+To deploy the worker to Cloudflare:
+```bash
+npm run deploy
+```
## `dist/server/importBuild.js`