analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.58k stars 247 forks source link

Build & Deploy on CloudFlare Pages issue #999

Closed dalenguyen closed 7 months ago

dalenguyen commented 7 months ago

Please provide the environment you discovered this bug in.

Workspace: Nx

Repo: https://github.com/dalenguyen/cloudflare-challange

Which area/package is the issue in?

Don't know / other

Description

I'm generating a new Analog app using Nx workspace. When I try to build and deploy the app to CloudFlare pages, there are issues locally and on cloud flare:

Locally

Here is my configuration for nitro:

   plugins: [
      analog({
        nitro: {
          output: {
            dir: "./dist/ai/analog/public",
            serverDir: "./dist/ai/analog/public/_worker.js",
          },
        },
      }),

After running the build, there're two places where it save the file. This one is in the wrong place:

image

It suppose to be in the same place under dist:

image

On CloudFlare

Looks like it only generate the client and ssr folder.

image

There's no dist/ai/analog/public being generated.

Please provide the exception or error you saw

No response

Other information

No response

I would be willing to submit a PR to fix this issue

brandonroberts commented 7 months ago

When you deploy to Cloudflare, it builds correctly for the environment. If you want to do it locally, you need to specify the BUILD_PRESET

BUILD_PRESET=cloudflare-pages ng build
dalenguyen commented 7 months ago

It does work if I set the path to ai/dist/ai/analog/public in CloudFlare. Is it the build issue (feature) in Nx workspace? 🤔