如果我通过闭包编译器或uglifyjs运行这段代码,this.init不会缩短..任何人都可以告诉我为什么会这样?
function test() {
var v = "abc";
this.init = function() {
alert('var = ' + v + ' and func = ' + f());
f2();
}
function f() {
return 'def';
}
function f2() {
v = "ghi";
alert('blabla');
alert('filler');
}
}
test();
Run Code Online (Sandbox Code Playgroud)
uglifyjs把它变成:
function test(){function c(){a="ghi",alert("blabla"),alert("filler")}function b(){return"def"}var a="abc";this.init=function(){alert("var = "+a+" and func = "+b()),c()}}test()
Run Code Online (Sandbox Code Playgroud)
美化是:
function test() {
function c() {
a = "ghi", alert("blabla"), alert("filler")
}
function b() {
return "def"
}
var a = "abc";
this.init …Run Code Online (Sandbox Code Playgroud) compression jquery function google-closure-compiler uglifyjs
我遇到了在Heroku上部署的问题,在rake任务中失败了
rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
在底部是我积累的错误
该错误发生在uglifier.
我怀疑这个问题可能与日历中包含许多本地化有关.
我通过设置来解决错误:
# Compress JavaScripts and CSS
config.assets.compress = false
Run Code Online (Sandbox Code Playgroud)
当临时文件被清理时,我无法检查文件.我也无法让RubyMine中的调试器停在断点处.
如果这是一个错误的任何想法?有什么办法让临时文件不被删除?任何使RubyMine调试器在rake任务上工作的方法(是的,使用EAP 112-291尝试了显而易见的事情.
rake资产:预编译:所有RAILS_ENV =生产RAILS_GROUPS =资产佣金中止!意外的字符''(行:21454,col:0,pos:641761)
新的JS_Parse_Error(/tmp/execjs20111231-15374-1fve7h4.js:497:22)在js_error(/tmp/execjs20111231-15374-1fve7h4.js:505:15)处于parse_error(/ tmp/execjs20111231-15374-1fve7h4)时出错. js:596:17)在Object.next_token [作为输入](/tmp/execjs20111231-15374-1fve7h4.js:839:17)at next(/tmp/execjs20111231-15374-1fve7h4.js:943:37)at Object .semicolon [as 1](/tmp/execjs20111231-15374-1fve7h4.js:986:38)在prog1(/tmp/execjs20111231-15374-1fve7h4.js:1527:28)的simple_statement(/ tmp/execjs20111231-15374-) 1fve7h4.js:1123:35)/tmp/execjs20111231-15374-1fve7h4.js:1031:35 attmp/execjs20111231-15374-1fve7h4.js:1510:32
我最近从Jammit迁移到Rails Asset Pipeline.除了几个出牙问题,一切都运作良好.
但是,我最近开始在生产中遇到一些脚本错误,并意识到我几乎不可能调试它们.我之前已将Jammit配置为保留换行符,但否则会删除javascript文件中的所有空格.这是为了确保如果我看到运行时错误,我将能够找到有问题的行,并希望找出问题所在.使用Rails Asset Pipeline和默认的:uglifier压缩器,它会显示删除所有空格,包括换行符,因此我的脚本错误不会告诉我问题在代码中的位置.
有没有人知道配置Rails Asset Pipeline以保留换行符以便可以调试代码?
马特
npm在构建js应用程序时,我需要帮助在脚本中运行一系列命令.
现在我正在运行这一行:
"scripts": {
"build-js": "browserify src/app/main.js --debug | exorcist dist/app.js.map > dist/app.js",
}
Run Code Online (Sandbox Code Playgroud)
浏览并提取源图.但我也希望能够缩小uglifyjs2.
如何管道uglifyjs以获得具有外部源图的缩小源?
React根据BSD样式许可证分发.当我缩小生成的JS文件时如何满足这个要求?即许多库具有许可标头,其中包括特殊元数据但不包括React.
我使用webpack和uglifyjs进行缩小.Uglifyjs可以选择保留评论,但它包含所有内容.还有一个uglify插件,但我无法将其与webpack集成.
我想Obfuscate + Minify我的Angular JS代码,以便不公开它,如果有人试图解码它,那么就把它变成障碍.代码正在运行服务器.
注意:将来我们计划将http转换为https.
我已经看到很多选项,如Gulp,Google Closure Compiler,UglifyJS等以及许多用户可以下载和混淆代码的工具,如jsob,javascript obfuscate等.
我需要建议并提出一些问题.
我在尝试覆盖被丑化的文件时遇到问题。不幸的是,我无法输出到不同的文件名。
以下是一些尝试:
uglifyjs dist/main.*.js --compress drop_console=true --overwrite
find ./dist -name "main.*.js" | xargs uglifyjs --compress drop_console=true --overwrite file
find ./dist -name "main.*.js" | xargs uglifyjs -f --compress drop_console=true --overwrite file -o file
每次它只是打印到 STDOUT。如果我做类似的uglifyjs dist/main.*.js --compress drop_console=true -o main.min.js事情就会奏效。
有什么想法吗?
我曾经遇到过UglifyJS for Webpack和ES6模块的问题:
来自UglifyJs的static/js/vendor.6ccd9e38979a78765c7a.js中的错误Unexpected token:name(features)[./ node_modules/pica/lib/mathlib.js:19,0] [static/js/vendor.6ccd9e38979a78765c7a.js:39003, 6]
我读到Webpack插件的新测试版支持ES6:
https://github.com/webpack-contrib/uglifyjs-webpack-plugin
new webpack.optimize.UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 8, // I also tried 7 and 6
parse: {},
mangle: {
properties: {
// mangle property options
}
},
output: {
comments: false,
beautify: false
},
compress: {},
warnings: true
}
}),
Run Code Online (Sandbox Code Playgroud)
但是,现在我又收到了另一个错误:
来自UglifyJs的static/js/vendor.6ccd9e38979a78765c7a.js中的错误Unexpected token:name(features)[static/js/vendor.6ccd9e38979a78765c7a.js:39003,6]
可能是什么问题呢?
I'll trying to use uglify with webpack but got this error:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration has an unknown property 'optimization'. These properties are valid:
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
Run Code Online (Sandbox Code Playgroud)
I have
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
Run Code Online (Sandbox Code Playgroud)
and
optimization: {
minimizer: [new …Run Code Online (Sandbox Code Playgroud) uglifyjs ×10
webpack ×3
javascript ×2
browserify ×1
compression ×1
ecmascript-6 ×1
function ×1
gulp ×1
heroku ×1
jquery ×1
minify ×1
npm ×1
obfuscation ×1
reactjs ×1
source-maps ×1
sprockets ×1
uglifyjs2 ×1