Skip to content

Assets entries in the manifest do not preserve the original file extension #8764

@ElMassimo

Description

@ElMassimo

Describe the bug

#6649 added assets to the manifest, but the entries are invalid for Sass/Less/Stylus stylesheets, as it's erasing the original extension from the manifest entry names and src.

For example, for style.scss the entry is:

  "style.css": {
    "file": "assets/style.a5c756ae.css",
    "src": "style.css"
  }

In contrast, Vite does preserve .ts extensions:

  "main.ts": {
    "file": "assets/main.ts.a1959a64.js",
    "src": "main.ts",

For any backend integration to map files correctly, it's desirable to preserve the extension for assets as well:

  "style.scss": {
    "file": "assets/style.a5c756ae.css",
    "src": "style.scss"
  }

Background 📜

This is the behavior that vite-plugin-ruby implements, but it no longer works with Vite 3.

I believe this change is currently preventing Vite Ruby from trying to recover the original extension, making #6649 a breaking change for many Vite Ruby projects.

If the manifest preserves the extensions, this would greatly simplify all backend integrations, including Vite Ruby.

Reproduction

Run npm run build or see the manifest, notice that both the entry name and the src are incorrect.

Additionally, this failing test run demonstrates the issue.

System Info

System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 109.84 MB / 16.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.13.1 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/node
    Yarn: 1.22.17 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/yarn
    npm: 8.1.2 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/npm
  Browsers:
    Chrome: 102.0.5005.115
    Firefox: 101.0
    Safari: 15.2

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions