Uglifyjs: How to keep ES6 class name property

Created on 19 Nov 2015  路  3Comments  路  Source: mishoo/UglifyJS

I'm using webpack with webpack.optimize.UglifyJsPlugin on an Angular app, I'd like to use this syntax to define controller:

// in header.controller.js
class HeaderController {...}
export default HeaderController;
// in app.js
import HeaderController from './header.controller'
angular.module('app', [])
    .controller(HeaderController.name, HeaderController);

However, I found uglify will change the class name, how to disable this?

All 3 comments

Assuming you're transpiling using babel. IIRC they transpile classes into functions. Have you tried using --keep-fnames?

@fabiosantoscode I tried with

new webpack.optimize.UglifyJsPlugin({
    compress: {
        warnings: false,
        keep_fnames: true
    }
})

and

new webpack.optimize.UglifyJsPlugin({
    compress: {
        warnings: false
    }
    mangle: {
        keep_fnames: true
    }
})

both not work

We are not the authors of webpack. You should ask then your question.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

utdrmac picture utdrmac  路  4Comments

GrosSacASac picture GrosSacASac  路  3Comments

gabmontes picture gabmontes  路  5Comments

andreialecu picture andreialecu  路  5Comments

pvdz picture pvdz  路  3Comments