最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to disable in Webpack to rename of function names? TypeScript, Javascript - Stack Overflow

matteradmin18PV0评论

How to disable in Webpack to rename of function names? I have got in my code this name of class:

import { MenuBlocksMenuPage } from "../pages/menu/blocks/menupage";

But in compiled file the row becomes to unreadable string.

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__pages_menu_blocks_menupage__ = __webpack_require__(669);

My question is: What is the option in Webpack that can to disable the change of class or functions name?

How to disable in Webpack to rename of function names? I have got in my code this name of class:

import { MenuBlocksMenuPage } from "../pages/menu/blocks/menupage";

But in compiled file the row becomes to unreadable string.

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__pages_menu_blocks_menupage__ = __webpack_require__(669);

My question is: What is the option in Webpack that can to disable the change of class or functions name?

Share Improve this question edited Feb 17, 2017 at 14:38 Alexander Zakusilo asked Feb 17, 2017 at 14:17 Alexander ZakusiloAlexander Zakusilo 1,5564 gold badges18 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 30

I am running into the same issue, the TerserPlugin pointed to by Andrew Mackie's link will address the issue, but is also a pretty heavy solution. One option would be changing how the optimization setting in webpack works. A convenient approach (without having given in huge thought) would be:

optimization: {
  minimize: true|false|"compress"|"preserve"
}

"compress" would remove white space but not mangle "preserve" would minimize but not mangle function and class names

Here is the Terser configuration for webpack.conf:

optimization: {
    minimize: true,
    minimizer: [
        new TerserPlugin({
            terserOptions: {
                keep_classnames: true,
                keep_fnames: true
            }
          })
        ]
  },

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far