Vite build works locally, but fails on cloudflare
I recently added around 100 5Mb images to my project, which successfully builds locally, but when I try to build & deploy on pages it fails. What's interesting is that the failure is not the same each time. Sometimes it fails to resolve different image paths.
How can I fix this?
3 Replies
2024-04-05T18:57:30.344472Z Cloning repository...
2024-04-05T18:58:20.971015Z From https://github.com/StarlightLabsCo/discord-dnd
2024-04-05T18:58:20.971546Z * branch 7ae5a80f96b0260342280d9f671213eae31c58c7 -> FETCH_HEAD
2024-04-05T18:58:20.971649Z
2024-04-05T18:58:22.480564Z HEAD is now at 7ae5a80 Finish all race x class image combos.
2024-04-05T18:58:22.48108Z
2024-04-05T18:58:22.563904Z
2024-04-05T18:58:22.564742Z Using v2 root directory strategy
2024-04-05T18:58:22.590018Z Success: Finished cloning repository files
2024-04-05T18:58:24.351708Z No wrangler.toml file found
2024-04-05T18:58:24.43269Z Restoring from dependencies cache
2024-04-05T18:58:24.449575Z Restoring from build output cache
2024-04-05T18:58:26.107441Z Success: Dependencies restored from build cache.
2024-04-05T18:58:27.288004Z Detected the following tools from environment: [email protected], [email protected]
2024-04-05T18:58:27.288625Z Installing bun 1.0.30
2024-04-05T18:58:27.426952Z Downloading Bun v1.0.30...
2024-04-05T18:58:28.59847Z Archive: /tmp/asdf-bun.O6QD/bun.zip
2024-04-05T18:58:29.323382Z inflating: /opt/buildhome/.asdf/downloads/bun/1.0.30/bun
2024-04-05T18:58:29.388959Z Installing Bun v1.0.30...
2024-04-05T18:58:29.482189Z Bun v1.0.30 is installed successfully!
2024-04-05T18:58:29.984839Z Executing user command: bun run build
2024-04-05T18:58:30.239667Z $ bun install --frozen-lockfile && vite build
2024-04-05T18:58:30.258973Z bun install v1.0.30 (1424a196)
2024-04-05T18:58:33.179881Z
2024-04-05T18:58:33.180204Z + client@workspace:apps/client
2024-04-05T18:58:33.18033Z + database@workspace:packages/database
2024-04-05T18:58:33.180461Z + server@workspace:apps/server
2024-04-05T18:58:33.180571Z + starlight-api-types@workspace:packages/starlight-api-types
2024-04-05T18:58:33.180681Z + @repo/eslint-config@workspace:packages/eslint-config
2024-04-05T18:58:33.180837Z + @repo/typescript-config@workspace:packages/typescript-config
2024-04-05T18:58:33.180937Z + [email protected]
2024-04-05T18:58:33.181045Z + [email protected]
2024-04-05T18:58:33.181152Z + [email protected]
2024-04-05T18:58:33.181259Z
2024-04-05T18:58:33.181329Z 527 packages installed [2.93s]
2024-04-05T18:58:33.181587Z warn: @prisma/client's postinstall script took 2.6s
2024-04-05T18:58:33.181938Z
2024-04-05T18:58:33.649967Z [36mvite v5.2.6 [32mbuilding for production...[36m[39m
2024-04-05T18:58:33.697472Z transforming...
2024-04-05T18:58:34.628321Z [32m✓[39m 72 modules transformed.
2024-04-05T18:58:34.629204Z [31mx[39m Build failed in 957ms
2024-04-05T18:58:34.630664Z [31merror during build:
2024-04-05T18:58:34.630928Z RollupError: [31mCould not resolve "./halfOrc" from "src/assets/images/portraits/races/index.ts"[31m
2024-04-05T18:58:34.631028Z file: [36m/opt/buildhome/repo/apps/client/src/assets/images/portraits/races/index.ts[31m
2024-04-05T18:58:34.631104Z at getRollupError (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/parseAst.js:376:41)
2024-04-05T18:58:34.631673Z at error (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/parseAst.js:372:42)
2024-04-05T18:58:34.631771Z at ModuleLoader.handleInvalidResolvedId (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:18891:24)
2024-04-05T18:58:34.632315Z at file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:18851:26[39m
2024-04-05T18:58:34.642292Z error: script "build" exited with code 1
2024-04-05T18:58:34.645741Z Failed: Error while executing user command. Exited with error code: 1
2024-04-05T18:58:34.655333Z Failed: build command exited with code: 1
2024-04-05T18:58:35.6562Z Failed: error occurred while running build command
2024-04-05T18:57:30.344472Z Cloning repository...
2024-04-05T18:58:20.971015Z From https://github.com/StarlightLabsCo/discord-dnd
2024-04-05T18:58:20.971546Z * branch 7ae5a80f96b0260342280d9f671213eae31c58c7 -> FETCH_HEAD
2024-04-05T18:58:20.971649Z
2024-04-05T18:58:22.480564Z HEAD is now at 7ae5a80 Finish all race x class image combos.
2024-04-05T18:58:22.48108Z
2024-04-05T18:58:22.563904Z
2024-04-05T18:58:22.564742Z Using v2 root directory strategy
2024-04-05T18:58:22.590018Z Success: Finished cloning repository files
2024-04-05T18:58:24.351708Z No wrangler.toml file found
2024-04-05T18:58:24.43269Z Restoring from dependencies cache
2024-04-05T18:58:24.449575Z Restoring from build output cache
2024-04-05T18:58:26.107441Z Success: Dependencies restored from build cache.
2024-04-05T18:58:27.288004Z Detected the following tools from environment: [email protected], [email protected]
2024-04-05T18:58:27.288625Z Installing bun 1.0.30
2024-04-05T18:58:27.426952Z Downloading Bun v1.0.30...
2024-04-05T18:58:28.59847Z Archive: /tmp/asdf-bun.O6QD/bun.zip
2024-04-05T18:58:29.323382Z inflating: /opt/buildhome/.asdf/downloads/bun/1.0.30/bun
2024-04-05T18:58:29.388959Z Installing Bun v1.0.30...
2024-04-05T18:58:29.482189Z Bun v1.0.30 is installed successfully!
2024-04-05T18:58:29.984839Z Executing user command: bun run build
2024-04-05T18:58:30.239667Z $ bun install --frozen-lockfile && vite build
2024-04-05T18:58:30.258973Z bun install v1.0.30 (1424a196)
2024-04-05T18:58:33.179881Z
2024-04-05T18:58:33.180204Z + client@workspace:apps/client
2024-04-05T18:58:33.18033Z + database@workspace:packages/database
2024-04-05T18:58:33.180461Z + server@workspace:apps/server
2024-04-05T18:58:33.180571Z + starlight-api-types@workspace:packages/starlight-api-types
2024-04-05T18:58:33.180681Z + @repo/eslint-config@workspace:packages/eslint-config
2024-04-05T18:58:33.180837Z + @repo/typescript-config@workspace:packages/typescript-config
2024-04-05T18:58:33.180937Z + [email protected]
2024-04-05T18:58:33.181045Z + [email protected]
2024-04-05T18:58:33.181152Z + [email protected]
2024-04-05T18:58:33.181259Z
2024-04-05T18:58:33.181329Z 527 packages installed [2.93s]
2024-04-05T18:58:33.181587Z warn: @prisma/client's postinstall script took 2.6s
2024-04-05T18:58:33.181938Z
2024-04-05T18:58:33.649967Z [36mvite v5.2.6 [32mbuilding for production...[36m[39m
2024-04-05T18:58:33.697472Z transforming...
2024-04-05T18:58:34.628321Z [32m✓[39m 72 modules transformed.
2024-04-05T18:58:34.629204Z [31mx[39m Build failed in 957ms
2024-04-05T18:58:34.630664Z [31merror during build:
2024-04-05T18:58:34.630928Z RollupError: [31mCould not resolve "./halfOrc" from "src/assets/images/portraits/races/index.ts"[31m
2024-04-05T18:58:34.631028Z file: [36m/opt/buildhome/repo/apps/client/src/assets/images/portraits/races/index.ts[31m
2024-04-05T18:58:34.631104Z at getRollupError (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/parseAst.js:376:41)
2024-04-05T18:58:34.631673Z at error (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/parseAst.js:372:42)
2024-04-05T18:58:34.631771Z at ModuleLoader.handleInvalidResolvedId (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:18891:24)
2024-04-05T18:58:34.632315Z at file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:18851:26[39m
2024-04-05T18:58:34.642292Z error: script "build" exited with code 1
2024-04-05T18:58:34.645741Z Failed: Error while executing user command. Exited with error code: 1
2024-04-05T18:58:34.655333Z Failed: build command exited with code: 1
2024-04-05T18:58:35.6562Z Failed: error occurred while running build command
example of it failing to resolve, but different than the first
Turns out,this was git ignoring case! so I git put it as halfelf, when it was looking for halfElf
fixed it by doing
git config core.ignorecase false