Nodejs咕噜声混淆 [英] Nodejs grunt obfuscate

查看:58
本文介绍了Nodejs咕噜声混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Nodejs grunt 模块.我知道 grunt min 选项会缩小文件.但现在我需要混淆像谷歌关闭编译器这样的文件.grunt 有这个功能吗?

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?

推荐答案

grunt min 任务允许您设置 UglifyJS(grunt min 工具)选项,这可以让您更好地控制目标文件的变形和压缩方式.

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/牛仔/grunt/blob/master/docs/task_min.md#specifying-uglifyjs-options

https://github.com/mishoo/UglifyJS

来自 grunt task_min 文档:

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

这篇关于Nodejs咕噜声混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆