Reputation: 1505
When I bundle code below in development mode and run abc(),
class Foo { ... }
export function abc () { return new Foo(); }
I got Foo { ... }
.
But bundle with production mode, I got something like k { ... }
and I lost information about class name.
How can I avoid this?
In other words, I want to minify code except class name because I want to use source as a library with npm install my-github-repository
and require("abc")
.
Upvotes: 3
Views: 814
Reputation: 52
webpack configure sourcemap and then use the uglifyjs-webpack-plugin package to set the output souremap to keep the class name and function name
new UglifyJsPlugin({
sourceMap: true,
parallel: 4,
uglifyOptions: {
keep_classnames: true,
keep_fnames: true
}
})
Upvotes: 2