Skip to content

@font-face cause css-loader crash in 5.1.0 #1267

Closed
@lyz810

Description

@lyz810
  • Operating System: Mac 11.2.2
  • Node Version:14.2.0
  • NPM Version: 6.14.9
  • webpack Version: 5.24.2
  • css-loader Version: 5.1.0

Expected Behavior

Don't crash

Actual Behavior

style.less:13 Uncaught Error: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
TypeError: Cannot read property 'raw' of null

Code

The following rules will cause css-loader crash

@font-face {
    font-family: "anticon";
    src: url("//at.alicdn.com/t/font_1434092639_4910953.eot?#iefix") format("embedded-opentype"),
    /* this comment is required */
    url("//at.alicdn.com/t/font_1434092639_4910953.woff") format("woff");
}

The following rules will NOT cause css-loader crash

@font-face {
    font-family: "anticon";
    src: url("//at.alicdn.com/t/font_1434092639_4910953.eot?#iefix") format("embedded-opentype"),
    // this comment is required
    url("//at.alicdn.com/t/font_1434092639_4910953.woff") format("woff");
}

OR

@font-face {
    font-family: "anticon";
    src: url("//at.alicdn.com/t/font_1434092639_4910953.eot?#iefix") format("embedded-opentype"),
    url("//at.alicdn.com/t/font_1434092639_4910953.woff") format("woff");
}

How Do We Reproduce?

Create a font-face rule, use /**/ comment between to url in src attribute
This will make node.raws.value to be null at https://github.com/webpack-contrib/css-loader/pull/1264/files#diff-4a96d95d621a313e78a0a620a8763aaf8f975c2fcdf6feddd6d2db94314673e4R71
so, node.raws.value.raw will cause TypeError: Cannot read property 'raw' of null
It should be node.raws.value!= null,not only typeof node.raws.value === "undefined"
@alexander-akait @cap-Bernardito

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions