Skip to content

Can not inline multiple css #25

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

Closed
mixueXiang opened this issue Sep 17, 2020 · 6 comments
Closed

Can not inline multiple css #25

mixueXiang opened this issue Sep 17, 2020 · 6 comments

Comments

@mixueXiang
Copy link

mixueXiang commented Sep 17, 2020

When there are multiple css in the page that need to be inlined,a part of css will not be inlined。
I readed the source code in v4.ts, maybe the problem is here:

private prepareCSSStyle(data: BeforeAssetTagGenerationData) {
    data.assets.css.forEach((cssLink, index) => {
      if (this.isCurrentFileNeedsToBeInlined(cssLink)) {
        const style = this.getCSSStyle({
          cssLink,
          publicPath: data.assets.publicPath,
        })

        if (style) {
          if (this.cssStyleMap.has(data.plugin)) {
            this.cssStyleMap.get(data.plugin)!.push(style)
          } else {
            this.cssStyleMap.set(data.plugin, [style])
          }
          // prevent generate <link /> tag
          data.assets.css.splice(index, 1)
        }
      }
    })
  }

for example:
image

the element in the middle is deleted, it results in a part of css cannot be inlined.

@mixueXiang
Copy link
Author

I want to be sure that if there is a historical reason for this code, can I pull a request to resolve this problem?

@l5oo00
Copy link

l5oo00 commented Sep 18, 2020

@mixueXiang I think it is a bug.

@runjuu
Copy link
Owner

runjuu commented Sep 18, 2020

Hi @mixueXiang , Sorry for the late reply. This does seem to be a problem and I'm looking forward to your pull request! 😃

@mixueXiang
Copy link
Author

@runjuu , Thanks for your reply, I pulled a request, can you help me to review changes?

@runjuu runjuu mentioned this issue Sep 18, 2020
@runjuu
Copy link
Owner

runjuu commented Sep 18, 2020

Hi @mixueXiang , I've released a new version for it.

@mixueXiang
Copy link
Author

@runjuu Thanks, new version works well.

@runjuu runjuu closed this as completed Sep 18, 2020
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

No branches or pull requests

3 participants