Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudflare.StaticSite does not work #1292

Open
Ernxst opened this issue Oct 16, 2024 · 1 comment
Open

cloudflare.StaticSite does not work #1292

Ernxst opened this issue Oct 16, 2024 · 1 comment
Assignees

Comments

@Ernxst
Copy link
Contributor

Ernxst commented Oct 16, 2024

I believe this is related to 1044 but this also happens with sst deploy. Not sure when this issue was introduced, but I noticed a while back the react dev build was included in my cloudflare worker, despite me having:

define: {
  "process.env.NODE_ENV": "'production'"
}

In the build.esbuild of my worker.

In the output artefact, I can see that process.env.NODE_ENV isn't replaced at all. In a separate app, I tried to create a cloudflare static site, but that never worked, failing with the following error:

"exceptions": [
  {
    "stack": "    at respond (worker.mjs:50:7)\n    at fetch (worker.mjs:15:38)",
    "name": "ReferenceError",
    "message": "SST_ASSET_MANIFEST is not defined",
    "timestamp": 1729071695262
  }
]

Inspecting the source code, I can see that SST_ASSET_MANIFEST is also supposed to be replaced with the actual manifest JSON using define, so I can only assume these two things broke at the same time.

Here's a reproduction repo; after running sst deploy, you'll still see unreplaced process.env.NODE_ENV in the output artifact of the worker and unreplaced SST_ASSET_MANIFEST in the web router output file. Trying to access the url of the static site takes you to an error page and inspecting the logs will show the same error as above.

@Ernxst
Copy link
Contributor Author

Ernxst commented Oct 17, 2024

I don't know any go but just took a look at the source where I think workers get built (here) and there doesn't seem to be any mention of the define option

@Ernxst Ernxst changed the title esbuild "define" does not work cloudflare.StaticSite does not work Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants