本页还没有译文
本页 12 段还没译成日本語,下面显示的是英文原文。Start from scratch
还没翻译译自英文(developers.cloudflare.com)本页 12 段都还没译
Use Workers Static Assets Instead
You should use Workers Static Assets to host full-stack applications instead of Workers Sites. It has been deprecated in Wrangler v4, and the Cloudflare Vite plugin does not support Workers Sites. Do not use Workers Sites for new projects.
This guide shows how to quickly start a new Workers Sites project from scratch.
Getting started
-
Ensure you have the latest version of git and Node.js installed.
-
In your terminal, clone the
worker-sites-templatestarter repository. The following example creates a project calledmy-site:git clone --depth=1 --branch=wrangler2 https://github.com/cloudflare/worker-sites-template my-site -
Run
npm installto install all dependencies. -
You can preview your site by running the
wrangler devcommand:wrangler dev -
Deploy your site to Cloudflare:
npx wrangler deploy
Project layout
The template project contains the following files and directories:
public: The static assets for your project. By default it contains anindex.htmland afavicon.ico.src: The Worker configured for serving your assets. You do not need to edit this but if you want to see how it works or add more functionality to your Worker, you can editsrc/index.ts.wrangler.jsonc: The file containing project configuration. Thebucketproperty tells Wrangler where to find the static assets (e.g.site = { bucket = "./public" }).package.json/package-lock.json: define the required Node.js dependencies.
Customize the wrangler.jsonc file:
-
Change the
nameproperty to the name of your project:{ "$schema": "./node_modules/wrangler/config-schema.json", "name": "my-site" }"$schema" = "./node_modules/wrangler/config-schema.json" name = "my-site" -
Consider updating
compatibility_dateto today's date to get access to the most recent Workers features:{ "compatibility_date": "yyyy-mm-dd" }compatibility_date = "yyyy-mm-dd" -
Deploy your site to a custom domain that you own and have already attached as a Cloudflare zone:
{ "route": "https://example.com/*" }route = "https://example.com/*"Note
Refer to the documentation on Routes to configure a
routeproperly.
Learn more about configuring your project.