babel-loader icon indicating copy to clipboard operation
babel-loader copied to clipboard

Why does Babel loader beautify code automatically?

Open hongrunhui opened this issue 4 years ago • 2 comments

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:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

  • What is the expected behavior?

  • What is the motivation / use case for changing the behavior?

hongrunhui avatar May 08 '21 10:05 hongrunhui

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.

JLHwung avatar May 08 '21 13:05 JLHwung

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!

hongrunhui avatar May 08 '21 14:05 hongrunhui