babel / babel-loader

📦 Babel loader for webpack
MIT License
4.83k stars 451 forks source link

Why does Babel loader beautify code automatically? #905

Open hongrunhui opened 3 years ago

hongrunhui commented 3 years ago

I need help

Why does Babel loader beautify code automatically? I want to keep it as it is. Is there any way to set it?

Webpack Version: 5.30.0

Babel Core Version: 7.13.14

Babel Loader Version: 8.2.2

Please tell us about your environment: OSX 11 Current behavior:

image

Expected/desired behavior:

JLHwung commented 3 years ago

Babel does not try to preserve the code styles of input. If you want to preserve whitespaces, you can use recast. Or in your cases, if you want to minify the output, you can pass the Babel generated code to terser.

hongrunhui commented 3 years ago

I don't want to minify code , I just want preserve the code styles of input, i remember the lower version babel-loader will not beautify code automatically if it is no way to config , OK, I will try other way, thx!