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

Static manifest.json file is overridden with generated file #5803

Closed
CaptainCodeman opened this issue Aug 3, 2022 · 10 comments · Fixed by #5874
Closed

Static manifest.json file is overridden with generated file #5803

CaptainCodeman opened this issue Aug 3, 2022 · 10 comments · Fixed by #5874
Labels
bug Something isn't working vite
Milestone

Comments

@CaptainCodeman
Copy link
Contributor

CaptainCodeman commented Aug 3, 2022

Describe the bug

A manifest file added to the static folder i.e. /static/manifest.json is overwritten with a generated SvelteKit file at runtime (happens with adapter-node & adapter-auto).

Reproduction

Add /static/manifest.json file:

{
  "name": "test"
}

Build / run app, request /manifest.json, response is like:

{
  ".svelte-kit/runtime/client/start.js": {
    "file": "_app/immutable/start-1e83f480.js",
    "src": ".svelte-kit/runtime/client/start.js",
    "isEntry": true,
    "imports": [
      "_index-e11c2291.js",
      "_index-b191a7c7.js",
      "_singletons-eca981c1.js"
    ],
    "dynamicImports": [
      "src/routes/__layout.svelte",
      ".svelte-kit/runtime/components/error.svelte",
      "src/routes/folder/[...path]/__layout.svelte",
      "src/routes/about/index.svelte",
      "src/routes/cart/index.svelte",
      "src/routes/folder/[...path]/index.svelte",
      "src/routes/index.svelte",
      "src/routes/photo/[id].svelte"
    ]
  },
  ...

Logs

No response

System Info

System:
    OS: macOS 12.5
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 51.80 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - /usr/local/bin/node
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 102.1.39.111
    Chrome: 104.0.5112.79
    Chrome Canary: 106.0.5216.0
    Edge: 103.0.1264.77
    Firefox: 102.0.1
    Safari: 15.6
    Safari Technology Preview: 16.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64 
    @sveltejs/adapter-node: next => 1.0.0-next.85 
    @sveltejs/kit: next => 1.0.0-next.401 
    svelte: ^3.49.0 => 3.49.0 
    vite: ^3.0.4 => 3.0.4

Severity

serious, but I can work around it

Additional Information

manifest.json is specifically mentioned as an example of using a static file:

assets — a place to put static files that should have stable URLs and undergo no processing, such as favicon.ico or manifest.json

@benmccann benmccann added the vite label Aug 4, 2022
@benmccann
Copy link
Member

manifest.json is a static file that Vite creates in the output directory and Vite copies the static assets to the output directory as well, so this seems like an issue that would need changes in Vite to address. Can you file an issue there? See https://github.com/sveltejs/kit#bug-reporting

@CaptainCodeman
Copy link
Contributor Author

It looks like it's a configurable option for Vite, but something SK manages and uses.

It sets it to be generated here, using it here

I don't know if it's used at runtime or just as part of the build process, but maybe a less-likely-to-conflict fixed name could be used instead of the default or a temporary name created, that doesn't exists in the static files?

@benmccann
Copy link
Member

SvelteKit needs it. We don't control the name. Vite hardcodes that. I think that the real issue isn't the name, but rather that it outputs it to the directory where the results go. It should probably go to a separate configurable directory.

@CaptainCodeman
Copy link
Contributor Author

The name can be set (it defaults to manifest.json if the option is set to true, but it can take a filename as well). So SvelteKit can control what file is used.

https://vitejs.dev/config/build-options.html#build-manifest

It looks like Vite has options to have the assetDir as some place other than outDir so perhaps it's a case of just altering the structure that SK uses?

@frederikhors
Copy link
Contributor

This is a huge problem for us! Just found! 1.0.0-next.394.

Is there any workaround for now?

@PatrickG
Copy link
Member

PatrickG commented Aug 7, 2022

Is there any workaround for now?

You could simply name your manifest manifest.webmanifest.

That's the official file extension for webmanifests anyway.
https://developer.mozilla.org/de/docs/Web/Manifest

@frederikhors
Copy link
Contributor

You could simply name your manifest manifest.webmanifest.

It works amazingly! Thanks!

@benmccann benmccann reopened this Aug 8, 2022
@frederikhors

This comment was marked as resolved.

@benmccann

This comment was marked as resolved.

@benmccann
Copy link
Member

I just noticed that this bug is affecting kit.svelte.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants