html-bundler-webpack-plugin icon indicating copy to clipboard operation
html-bundler-webpack-plugin copied to clipboard

Inline css question?

Open niansanchujiu opened this issue 2 years ago • 7 comments

Inline css?inline may fail to inline unexpectedly, I don't know how to determine this error situation For example, in my project there is a html main.js?inline, style.css?inline are all inlined normally, but I added several style2.css?inline... They can't be inlined normally, but are independent CSS

In order to reproduce the bug, a test2 project was created. The path configuration is the same but the files are different. The css is simplified and inlined normally. Once the css of the project is replaced with test, the problem occurs. Then the replaced css content is deleted to one line of code, but it still cannot be packaged. image

Try changing the file name index.css to new.css, but it still doesn't work

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel='stylesheet' href='new.css?inline' />

</head>
<body>
  
</body>
</html>

niansanchujiu avatar Nov 22 '24 09:11 niansanchujiu

Hello @niansanchujiu,

thanks for the issue report. I try to reproduce and fix it.

webdiscus avatar Nov 22 '24 09:11 webdiscus

@niansanchujiu

I can't reproduce the issue. The description of the issue is not clear defined. Please create a small repo with reproducible issue.

As reference take please the test case. On the base of this test case create your own repo with reproducible issue.

webdiscus avatar Nov 22 '24 10:11 webdiscus

@webdiscus Not sure when it will appear, it took a lot of attempts to reproduce it, try this case

niansanchujiu avatar Nov 23 '24 03:11 niansanchujiu

@niansanchujiu

thanks for the repo. I can reproduce the issue. I will fix it.

webdiscus avatar Nov 23 '24 13:11 webdiscus

@niansanchujiu

your HTML contains single quote (') for attributes therefore the parser don't find the CSS correct.

HTML specification allow using both the double " and single ' quotes for attributes. But best practice is using double quotes ".

Workaround

instead of single quotes:

<link rel='stylesheet' href='@pages/index/index.css?inline' />
<link rel='stylesheet' href='@styles/css.css?inline' />

use the double quotes:

<link rel="stylesheet" href="@pages/index/index.css?inline" />
<link rel="stylesheet" href="@styles/css.css?inline" />

P.S.

I will fix the bug with single quotes.

webdiscus avatar Nov 23 '24 14:11 webdiscus

@niansanchujiu

I have fixed the issue. Can you please test your project with the new version 4.4.3? Thanks!

webdiscus avatar Nov 23 '24 22:11 webdiscus

@webdiscus There is no problem at present, it should be the quotation mark problem. Thanks for the timely reply and solution

niansanchujiu avatar Nov 25 '24 02:11 niansanchujiu