rspack
rspack copied to clipboard
rspack.SwcCssMinimizerRspackPlugin generated wrong css content
System Info
System:
OS: Linux 6.2 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (2) x64 AMD EPYC 7763 64-Core Processor
Memory: 5.20 GB / 7.74 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 20.10.0 - ~/nvm/current/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 10.2.3 - ~/nvm/current/bin/npm
pnpm: 8.11.0 - ~/nvm/current/bin/pnpm
npmPackages:
@rspack/cli: latest => 0.4.5
@rspack/core: latest => 0.4.5
Details
SwcCssMinimizerRspackPlugin changes -160deg
to 200deg
etc., which causes wrong behavior
input
.text {
color: blue;
background: conic-gradient(
from -160deg at 50% 50%,
#e92a67 0deg,
#a853ba 120deg,
#2a8af6 240deg,
#e92a67 360deg
);
}
wrong output(rspack+rspack.SwcCssMinimizerRspackPlugin)
.text{color:blue;background:conic-gradient(from 200deg at 50%50%,#e92a67 0deg,#a853ba 120deg,#2a8af6 240deg,#e92a67 0deg)}
output(webpack+CssMinimizerPlugin)
.text{background:conic-gradient(from -160deg at 50% 50%,#e92a67 0deg,#a853ba 120deg,#2a8af6 240deg,#e92a67 1turn);color:blue}head{--webpack-rspack-repro-src_render_js:\.\/src\/render\.css}
Reproduce link
https://github.com/guomio/rspack-issue-SwcCssMinimizerRspackPlugin
Reproduce Steps
- git clone https://github.com/guomio/rspack-issue-SwcCssMinimizerRspackPlugin
- npm i
- npm run build
- see the output
It probably caused by SWC CSS parser, can you try using other css minimizer
It probably caused by SWC CSS parser, can you try using other css minimizer
@JSerFeng Indeed, webpack with the following config resulted in the same output. Other minimizers looks ok
optimization: {
minimize: true,
minimizer: [
isRunningWebpack
? new CssMinimizerPlugin({ minify: CssMinimizerPlugin.swcMinify })
: new rspack.SwcCssMinimizerRspackPlugin()
]
}
This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Fixed by https://github.com/swc-project/swc/pull/9072
And it is recommended to use LightningCssMinimizerRspackPlugin
, Rspack will enable LightningCssMinimizerRspackPlugin by default in v1.0.0, see https://www.rspack.dev/plugins/rspack/lightning-css-minimizer-rspack-plugin