Skip to content

[Bug]: rsbuild injectStyles: true and chunkSplit: all-in-one will inject lots \n and blank space with cssnano useless #3247

@sbyps

Description

@sbyps

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions