gpt4 book ai didi

node.js - Nodejs grunt混淆

转载 作者:搜寻专家 更新时间:2023-10-31 23:36:11 25 4
gpt4 key购买 nike

我正在使用 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 文档:

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

关于node.js - Nodejs grunt混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10669104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com