简体   繁体   中英

How to turn off webpack bundling changing class names for just 1 class?

I have a basic class in my code:

class MyClass1 {}

and I use webpack to compile the full code. After compilation all class names are changed by webpack to something like this:

D_Documents_GitHub_Project_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__["default"])(this, MyClass1);

For some reason I need a few classes in my entire code to keep their original name and not get renamed. What is the best way of achieving this?

I know I can import them externally and use webpack-externals to prevent bundling, but I was wondering if there is a way to do it with classes defined in the code itself, with maybe something like a decorator

According to the doc

exclude: {
  test: [
    ..,
    ..,
  ],
  exclude: [
    'src/configs/configs/some.extention'
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM