Skip to content

Quick question: Property name mangling #788

@IngwiePhoenix

Description

@IngwiePhoenix

I feel a bit dumb for not finding the option...

I am using UglifyJS through html-minifier and I would like to mangle property names. What is the way to go? this is my uglifyjs config that I use in WebPack and the minifier. I want to go down as much as I can, and part of that is mangling property names.

module.exports = {
    compress: {
        warnings: false,
        properties: true,
        sequences: true,
        dead_code: true,
        conditionals: true,
        comparisons: true,
        evaluate: true,
        booleans: true,
        unused: true,
        loops: true,
        hoist_funs: true,
        cascade: true,
        if_return: true,
        join_vars: true,
        //drop_console: true,
        drop_debugger: true,
        unsafe: true,
        hoist_vars: true,
        negate_iife: true,
    },
    //sourceMap: true,
    mangle: {
        toplevel: true,
        sort: true,
        eval: true,
        props: true // <-- Seemed to have no effect...
    },
    output: {
        space_colon: false,
        comments: function(node, comment) {
            var text = comment.value;
            var type = comment.type;
            if (type == "comment2") {
                // multiline comment
                return /@copyright/i.test(text);
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions