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

CSS files are incorrectly excluded from assets array in manifest.json #17484

Closed
7 tasks done
Rich-Harris opened this issue Jun 14, 2024 · 0 comments · Fixed by #17623
Closed
7 tasks done

CSS files are incorrectly excluded from assets array in manifest.json #17484

Rich-Harris opened this issue Jun 14, 2024 · 0 comments · Fixed by #17623
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@Rich-Harris
Copy link
Contributor

Describe the bug

The manifest.json file emitted when build.manifest is true contains an object full of chunks, where some of those chunks have an assets array containing the path, relative to the output directory, of any assets referenced by that chunk.

For example if my stuff directory contains a file called text.txt, and I have a module like this...

export const stuff = import.meta.glob('./stuff/**', {
  eager: true,
  query: '?url'
});

...then the chunk that contains that module will look something like this in the manifest:

  "_stuff.js": {
    "file": "chunks/stuff.js",
    "name": "stuff",
    "assets": [
      "assets/text.txt"
    ]
  }

For whatever reason, .css files are excluded from this array — in other words if my stuff directory also contains a styles.css file, it will not be included in assets. (Nor is it included in the chunk's css array, not that it should be.)

The same thing happens if you import the asset directly:

import asset from './stuff/styles.css?url';

Reproduction

https://github.com/Rich-Harris/vite-glob-css

Steps to reproduce

npm install && npm run build, then inspect dist/.vite/manifest.json.

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 268.14 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/Library/pnpm/node
    npm: 10.7.0 - ~/Library/pnpm/npm
    pnpm: 9.2.0 - ~/Library/pnpm/pnpm
    bun: 1.0.10 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.57
    Chrome Canary: 124.0.6316.0
    Safari: 17.4.1
  npmPackages:
    vite: ^5.3.1 => 5.3.1

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) labels Jul 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants