node.js – Nodejs grunt obfuscate

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

解决方法

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

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

https://github.com/mishoo/UglifyJS

来自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的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...