Nodejs grunts obfuscation

I am using the runtime module for Nodejs. I know that the grunt min parameter minimizes files. But now I need to obfuscate files, such as the google closure compiler. Is there such a function?

+3
source share
1 answer

The grunt min task allows you to set the UglifyJS (grunt min tool) parameters, which can give you more control over how the destination file is distorted and compressed.

https://github.com/cowboy/grunt/blob/master/docs/task_min.md#specifying-uglifyjs-options

https://github.com/mishoo/UglifyJS

from the grunt task_min doc file:

Specifying UglifyJS options

In this example, custom UglifyJS mangle, squeeze and codegen options are
specified. The listed methods and their expected options are explained in
the API section of the UglifyJS documentation:

The mangle object is passed into the pro.ast_mangle method.
The squeeze object is passed into the pro.ast_squeeze method.
The codegen object is passed into the pro.gen_code method.

// Project configuration.
grunt.initConfig({
  min: {
    dist: {
      src: ['dist/built.js'],
      dest: 'dist/built.min.js'
    }
  },
  uglify: {
    mangle: {toplevel: true},
    squeeze: {dead_code: false},
    codegen: {quote_keys: true}
  }
});
+6
source

Source: https://habr.com/ru/post/1624262/


All Articles