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]: rsbuild injectStyles: true and chunkSplit: all-in-one will inject lots \n and blank space with cssnano useless #3247

Closed
sbyps opened this issue Aug 19, 2024 · 10 comments
Labels
🐞 bug Something isn't working

Comments

@sbyps
Copy link

sbyps commented Aug 19, 2024

Version

System:
    OS: macOS 14.6.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 50.20 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 127.0.6533.120
    Safari: 17.6
  npmPackages:
    @rsbuild/core: ^1.0.1-beta.14 => 1.0.1-beta.14 
    @rsbuild/plugin-check-syntax: ^1.0.1 => 1.0.1 
    @rsbuild/plugin-sass: ^1.0.1-beta.14 => 1.0.1-beta.14 
    @rsbuild/plugin-vue2: ^1.0.1-beta.14 => 1.0.1-beta.14

Details

following the official docs: https://rsbuild.dev/zh/config/output/inject-styles#%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF
then set config like
injectStyles: true,
chunkSplit: all-in-one

will inject lots \n and blank space with cssnano useless in js files

Reproduce link

https://github.com/sbyps/rspack-demo

Reproduce Steps

npm run build

cat the js files, search "\n ", will find lots of it
image

@sbyps
Copy link
Author

sbyps commented Sep 5, 2024

@chenjiahan this PR resolves some case with css \n; but we can found lots of \n in sourcemap and js files;
rsbuild version: 1.0.1-rc.4
https://github.com/sbyps/rspack-demo
image
image

@chenjiahan
Copy link
Member

This is as expected, the source map contains the source code

@sbyps
Copy link
Author

sbyps commented Sep 5, 2024

This is as expected, the source map contains the source code

image
this image is not sourcemap but production file, also has \n

@chenjiahan
Copy link
Member

Can you provide a reproduction?

@sbyps
Copy link
Author

sbyps commented Sep 5, 2024

Can you provide a reproduction?

https://github.com/sbyps/rspack-demo/tree/main

pnpm run build

cat dist/504.js dist/record-portrait.js

@chenjiahan
Copy link
Member

@sbyps
Copy link
Author

sbyps commented Sep 9, 2024

Fixed in https://github.com/web-infra-dev/rsbuild/releases/tag/v1.0.1-rc.5, can you have a try?

after bump rc.5, the css files don't have \n any more, but js files has \n as same;

https://github.com/sbyps/rspack-demo/tree/main

pnpm run build

cat dist/record-portrait.js

@chenjiahan chenjiahan reopened this Sep 9, 2024
@chenjiahan
Copy link
Member

You mean this one?

image

It is a string, not CSS.

@sbyps
Copy link
Author

sbyps commented Sep 14, 2024

You mean this one?

image

It is a string, not CSS.

it's vue template expression; should these \n   be minified?
image

@chenjiahan

@chenjiahan
Copy link
Member

I think it's unrelated to Rsbuild

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

2 participants