2012-05-19 47 views
3

我正在使用Nodejs grunt模塊。我知道咕嚕分鐘選項縮小文件。但現在我需要混淆像google closure編譯器這樣的文件。咕嚕有這個功能嗎?Nodejs grunt混淆

回答

6

分鐘的任務繁重,您可以設置UglifyJS(繁重分鐘工具)選項,它可以給你的目標文件是如何錯位和壓縮更大的控制權。

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

https://github.com/mishoo/UglifyJS

從咕嚕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} 
    } 
});