问题标签 [uglifyjs2]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
requirejs - 丑化 requirejs 项目中的源映射
我有一个 requirejs 项目,我正在用grunt-requirejs
( "grunt-contrib-requirejs": "~0.4.1"
) 编译成 1 个大文件:main.js
. 此任务启用了源映射生成:
requirejs: {
compile: {
options: {
baseUrl: 'source/js',
name: 'main',
optimize: 'none',
generateSourceMaps: true,
out: 'build/js/main.js',
wrap: true,
shim: requireJsConfig.shim,
paths: requireJsConfig.paths
}
}
}
之后,我main.js
使用grunt-uglify
( "grunt-contrib-uglify": "~0.2.7"
) 使用此配置将其缩小:
app: {
options: {
beautify : {
quote_keys: true
},
compress: false,
report: 'min',
sourceMap: 'build/js/main.js.map',
sourceMapIn: 'build/js/main.js.map', // input from requirejs
sourceMapIncludeSources: true
},
files: {
'build/js/main.js': ['build/js/main.js']
}
}
我想要一个源映射,它会告诉我源文件中的错误(那些 requirejs 消耗),但源映射根本拒绝工作。请帮助我到达那里,因为我已经感到无助了。
javascript - Uglify: generate source map but don't append sourceMappingURL comment
I am using UglifyJS2 to minify javascript source code.
I would like to generate source maps and point to those source maps using the X-SourceMap
HTTP header, instead of the //# sourceMappingURL
comment.
So, is there a facility to generate a sourcemap in uglify without appending the sourceMappingURL comment, short of just pulling it out myself?
gruntjs - uglifyjs 不混淆全局变量
我正在使用 uglifyjs(通过 grunt)并试图混淆一个全局变量,但它不起作用。我正在使用带有 mangle 的 'toplevel' 选项。
想知道是否有人可以回答为什么?
绕过 grunt 并直接使用 uglify,我使用的命令行是:
a.js的内容是:
丑陋的代码是:
我可以看到全局函数bar()
并且useAGlobal()
可以很好地混淆,但是为什么变量foo
保持不变?
如果我foo
用 'var' 关键字声明 as var foo = 5;
,那么它确实会被混淆。我在这里想念什么?
谢谢!