Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using Nodejs grunt module. I know grunt min option minifies a files. But now I need to obfuscate files like google closure compiler. Does grunt have that feature?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
655 views
Welcome To Ask or Share your Answers For Others

1 Answer

The grunt min task allows you to set UglifyJS (the grunt min tool) options, which can give you greater control on how the destination file is mangled 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:

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}
  }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...