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

[Bug]: output.inlineStyles: true doesn't seem to work in dev #2957

Closed
matteom-synth opened this issue Jul 18, 2024 · 7 comments
Closed

[Bug]: output.inlineStyles: true doesn't seem to work in dev #2957

matteom-synth opened this issue Jul 18, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@matteom-synth
Copy link

matteom-synth commented Jul 18, 2024

Version

System:
    OS: macOS 14.5
    CPU: (11) arm64 Apple M3 Pro
    Memory: 554.95 MB / 36.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Browsers:
    Chrome: 126.0.6478.182
    Safari: 17.5
  npmPackages:
    @rsbuild/core: 1.0.1-beta.3 => 1.0.1-beta.3
    @rsbuild/plugin-react: 1.0.1-beta.3 => 1.0.1-beta.3

Details

I'm not sure if I have some wrong expectations, but output.inlineStyles: true doesn't seem to inline stylesheets into the resulting HTML in dev. Is it supposed to work only on production builds?

Reproduce link

https://github.com/matteom-synth/rsbuild-issue-repro-3

Reproduce Steps

  1. Clone the repo.
  2. Run pnpm install.
  3. Run pnpm dev.
  4. Check the HTML output. My expectation is that, given that output.inlineStyles is set to true, the stylesheet should be inlined into the HTML. But it doesn't seem to be the case:
image
@matteom-synth matteom-synth added the bug Something isn't working label Jul 18, 2024
@matteom-synth matteom-synth changed the title [Bug]: output.inlineStyles doesn't seem to work [Bug]: output.inlineStyles: true doesn't seem to work Jul 18, 2024
@matteom-synth matteom-synth changed the title [Bug]: output.inlineStyles: true doesn't seem to work [Bug]: output.inlineStyles: true doesn't seem to work in dev Jul 18, 2024
@matteom-synth
Copy link
Author

matteom-synth commented Jul 18, 2024

After a quick investigation, I guess it's because of this check, right?

if (Object.keys(htmlPaths).length === 0 || isDev) {

Any reason why this is being disabled in dev? I guess it might be because it works better with HMR? Asking because sadly this is breaking our dev env (for a specific edge case) 🙃 because in our Webpack config by default styles are inlined in dev as well, and this is causing a differernt behaviour.
Any suggestion on how to inline CSS files in development?

@Thulof
Copy link
Contributor

Thulof commented Jul 18, 2024

After a quick investigation, I guess it's because of this check, right?

if (Object.keys(htmlPaths).length === 0 || isDev) {

Any reason why this is being disabled in dev? I guess it might be because it works better with HMR? Asking because sadly this is breaking our dev env (for a specific edge case) 🙃 because in our Webpack config by default styles are inlined in dev as well, and this is causing a differernt behaviour. Any suggestion on how to inline CSS files in development?

According to the docs, this option works only in production mode.

Whether to inline output style files (.css files) into HTML with `<style>` tags in production mode.

@matteom-synth
Copy link
Author

Crap I'm dumb as a rock. I didn't see that in the docs, sorry 🤦 I think the fact that Webpack defaults to them even in dev messed up with me. I'll try to find a way to make it work anyway. Thanks!

@chenjiahan
Copy link
Member

We can add a new option to enable inline styles in the dev mode, do you need to use it?

@matteom-synth
Copy link
Author

@chenjiahan thanks, it would be awesome but I'm sure you have other priorities :) so, no worries for now we'll deal with it in some other way.

@chenjiahan
Copy link
Member

Get, thanks for the feedback

@Thulof
Copy link
Contributor

Thulof commented Jul 23, 2024

Hi, I have created a pull request to solve this issue.

#3000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants