Skip to content

CSS/lazy/hmr: asset resource referenced in CSS isn't available to lazy loaded javascript chunk #20800

@Knagis

Description

@Knagis

Have you used AI?

None

Bug Description

When the same asset is included in both .css file (with experiments.css) and imported in an asynchronously loaded lazy chunk, it throws at runtime.

Link to Minimal Reproduction and step to reproduce

https://github.com/Knagis/webpack-css-lazy-font-issue

Expected Behavior

the asset resource is available in both CSS and JS chunks

Actual Behavior

ERROR
Cannot find module './font.woff2'
    at __webpack_require__ (http://localhost:8080/main.js:216:21)
    at fn (http://localhost:8080/main.js:415:21)
    at eval (webpack:///./mod.js?:2:69)
    at ./mod.js (http://localhost:8080/mod_js.js:18:1)
    at __webpack_require__ (http://localhost:8080/main.js:221:32)
    at fn (http://localhost:8080/main.js:415:21)

Environment

System:
    OS: Windows 11 10.0.26200
  Binaries:
    Node: 24.11.1
  Packages:
    html-webpack-plugin: ^5.6.6 => 5.6.6
    webpack: ^5.106.0 => 5.106.0
    webpack-cli: ^7.0.2 => 7.0.2
    webpack-dev-server: ^5.2.3 => 5.2.3

Is this a regression?

None

Last Working Version

No response

Additional Context

also fails on webpack 5.104.1, possible earlier as well.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions