Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lyz810 opened this issue Feb 28, 2021 · 4 comments · Fixed by #1268
Closed

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

lyz810 opened this issue Feb 28, 2021 · 4 comments · Fixed by #1268

Comments

@lyz810
Copy link

lyz810 commented Feb 28, 2021

  • 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

@alexander-akait
Copy link
Member

WIP

@alexander-akait
Copy link
Member

alexander-akait commented Mar 1, 2021

Weird, can't reproduce, but I think it can be from postcss-loader (some plugin change internal AST, it is bad), I will try to fix by adding more checks

@alexander-akait
Copy link
Member

@dreis-cgl
Copy link

Thanks! It's working properly with v5.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants