Skip to content

Inlined CSS is not working in SSR after 2.9 release #7913

@saurabhdaware

Description

@saurabhdaware

Describe the bug

I have a setup where I write inlined CSS in index.html file. I expect this inlined CSS to work as it is in dev-server and it did work before 2.9 however after 2.9 the inlined CSS turns into something like this in the source -

<script type="module" src="/?html-proxy&amp;index=0.css"></script>

Apparently, it is happening during vite.transformIndexHtml API. It returns new HTML with proxy script instead of actual inlined css. Due to this the CSS is not applied during the dev-server.

script type=module src=/?html-proxy&index=0.css

The build continues to work fine.

Reproduction

https://stackblitz.com/edit/github-12zodn-vbxsug?file=index.html&terminal=dev

Exactly same example on Vite 2.8.6 - https://stackblitz.com/edit/github-12zodn-34x7n1?file=package.json&terminal=dev (works as expected)

System Info

System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 520.12 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 7.19.1 - ~/.nvm/versions/node/v16.5.0/bin/npm
  Browsers:
    Brave Browser: 97.1.34.80
    Chrome: 100.0.4896.127
    Safari: 14.1.1

Used Package Manager

npm

Logs

/?html-proxy&index=0.css:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: cssfeat: ssrp2-edge-caseBug, but has workaround or limited in scope (priority)regressionThe issue only appears after a new release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions