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

Images in markdown not created in /_app/immutable/assets/XXX.png during build #8576

Closed
LukaHarambasic opened this issue Jan 17, 2023 · 1 comment

Comments

@LukaHarambasic
Copy link

LukaHarambasic commented Jan 17, 2023

Describe the bug

Problem

I'm building a blog with sveltekit, and mdsvex didn't grow on me, so I'm implementing my Markdown handling on my own. All markdown files are located in content/posts, which will be loaded via data/posts/api.server.ts. This gets initially loaded in the base +layout.server.ts, the data is then accessed in routes/posts/[slug]/+page.server.ts. Finally, display the data in routes/posts/[slug]/Entry.svelte.

To import the images to be processed via vite I use a custom unified plugin to import the files (inspired by this implementation).

This works locally running npm run dev, which before this change also wasn't working. As the error log references files like /_app/immutable/assets/copy_path_terminal-e7dd46f9.gif (I also get this error message for .png) which have a unique id appended to the original file name, I assume that the import works. I don't see the files in .svelte-kit/output/client/_app/immutable/assets - there are only the CSS files.

What have I tried?

  1. Pinned adapters to 1.0.0 - tried auto, static, and node (I thought this issue might be related Bad publish in @sveltejs/[email protected] breaking all builds (Netlify Vercel etc) #8530)
  2. Read through Asset handling multiple times and therefore used svelte-preprocess-import-assets
  3. I tried deploying to Netlify to see if it is a local problem - same error.
  4. Import assets via new URL(url, import.meta.url) - didn't even work locally.

Reproduction

I can't provide it as Stackblitz doesn't allow images to be uploaded, and this issue is about failing image imports. Happy to provide you a better reproduction if you let me know how.
https://github.com/LukaHarambasic/harambasic.de/tree/v3-sveltekit-reproduction-failing-build-imageswith

Logs

❯ npm run build

> [email protected] build
> vite build


vite v4.0.4 building for production...
transforming (39) node_modules/devalue/src/stringify.js23:04:39
<<REMOVED UNUSED CSS LOGS>>

✓ 370 modules transformed.
23:04:40 [vite-plugin-svelte] dom compile done.
package         files    time      avg
harambasic.de      10   0.22s   21.9ms

vite v4.0.4 building SSR bundle for production...
transforming (36) node_modules/@sveltejs/kit/src/runtime/client/utils.js

<<REMOVED UNUSED CSS LOGS>>

✓ 88 modules transformed.
23:04:40 [vite-plugin-svelte] ssr compile done.
package         files     time    avg
harambasic.de       9   37.0ms  4.1ms
@sveltejs/kit       1    2.6ms  2.6ms
.svelte-kit/output/server/vite-manifest.json                              3.85 kB
.svelte-kit/output/server/entries/pages/_page.ts.js                       0.05 kB
.svelte-kit/output/server/entries/pages/posts/_page.server.ts.js          0.08 kB
.svelte-kit/output/server/internal.js                                     0.14 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js                   0.22 kB
.svelte-kit/output/server/entries/pages/posts/_slug_/_page.server.ts.js   0.28 kB
.svelte-kit/output/server/entries/pages/_layout.svelte.js                 0.30 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js               0.83 kB
.svelte-kit/output/server/chunks/index.js                                 3.68 kB
.svelte-kit/output/server/chunks/helper.js                                3.77 kB
.svelte-kit/output/server/chunks/server-internal.js                       3.93 kB
.svelte-kit/output/server/entries/pages/_layout.server.ts.js              6.09 kB
.svelte-kit/output/server/entries/pages/posts/_slug_/_page.svelte.js      6.27 kB
.svelte-kit/output/server/entries/pages/posts/_page.svelte.js             9.48 kB
.svelte-kit/output/server/index.js                                       78.63 kB
Error: Not found: /_app/immutable/assets/copy_path_terminal-e7dd46f9.gif
    at resolve (file:///Users/luha/Development/harambasic.de/.svelte-kit/output/server/index.js:2493:18)
    at resolve (file:///Users/luha/Development/harambasic.de/.svelte-kit/output/server/index.js:2358:34)
    at Object.#options.hooks.handle (file:///Users/luha/Development/harambasic.de/.svelte-kit/output/server/index.js:2537:59)
    at respond (file:///Users/luha/Development/harambasic.de/.svelte-kit/output/server/index.js:2356:43)
file:///Users/luha/Development/harambasic.de/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:27
                                throw new Error(format(details));
                                      ^

Error: 404 /_app/immutable/assets/copy_path_terminal-e7dd46f9.gif (linked from /posts/quickly-copying-paths-to-the-terminal-on-macos)
    at file:///Users/luha/Development/harambasic.de/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:27:11
    at save (file:///Users/luha/Development/harambasic.de/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:346:4)
    at visit (file:///Users/luha/Development/harambasic.de/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:195:3)
[vite-plugin-sveltekit-compile] Prerendering failed with code 1
error during build:
Error: Prerendering failed with code 1
    at ChildProcess.<anonymous> (file:///Users/luha/Development/harambasic.de/node_modules/@sveltejs/kit/src/exports/vite/index.js:599:15)
    at ChildProcess.emit (node:events:527:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

System Info

System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
    Memory: 81.41 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Brave Browser: 102.1.39.111
    Chrome: 108.0.5359.124
    Firefox: 108.0.2
    Safari: 15.5
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.1 
    @sveltejs/kit: ^1.0.0 => 1.1.2 
    svelte: ^3.54.0 => 3.55.1 
    vite: ^4.0.0 => 4.0.4

Severity

blocking all usage of SvelteKit

Additional Information

I don't know if the problem is SveleKit, Vite, or the unified plugin, but as there was an issue with the adapters I thought I'll start here with my problem. Let me know if you need additional information.

Cheers,
Luka

@Rich-Harris
Copy link
Member

Closing as duplicate of #5240

@Rich-Harris Rich-Harris closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
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