Skip to content

v0.20.15 Regression: Build fails with Cannot read properties of undefined (reading '0') when using ?inline CSS #2115

@TejeshJadhav-cactus

Description

@TejeshJadhav-cactus

Describe the bug

After upgrading from 0.20.14 to 0.20.15, the build process fails with a TypeError: Cannot read properties of undefined (reading '0').

The error originates from WXT's internal Vite builder within the assetFileNames hook. It appears the logic introduced in the latest version assumes assetInfo.name is always a string. However, when CSS is imported using the ?inline query (a common pattern for Shadow DOM injection), Vite/Rollup can emit assets where the name is undefined, causing the internal WXT hook to crash.

Reproduction

A minimal setup importing CSS as a string triggers the failure:

src/entrypoints/example.content.ts

import styles from './styles.css?inline';

export default defineContentScript({
  matches: ['*://*/*'],
  main(ctx) {
    console.log("Inlined CSS:", styles);
  },
});

src/entrypoints/styles.css

.test { color: blue; }

Steps to reproduce

  1. Use wxt@0.20.15.
  2. Import a CSS file with the ?inline suffix in a content script.
  3. Run wxt build or wxt dev.
  4. The build fails with the following stack trace:
ERROR [vite:css-post] Cannot read properties of undefined (reading '0')

     at assetFileNames (/node_modules/wxt/dist/core/builders/vite/index.mjs:82:56)
     at getCssAssetDirname (/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:36210:9)
     at resolveAssetUrlsInCss (/node_modules/vite/dist/node/chunks/dep-C6uTJdX2.js:36329:73)

System Info

System:
    OS: macOS 26.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 306.31 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.18.0
    npm: 10.9.3
    pnpm: 8.15.7
  Browsers:
    Brave Browser: 142.1.84.132
    Chrome: 144.0.7559.133
    Firefox: 95.0.2
    Safari: 26.2
  npmPackages:
    vite: ^4.4.9 => 4.4.9

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions