Capistrano 部署后 uglify-js 挂钩输出但不写入文件
我面临着一个奇怪的问题,这肯定不难,但我似乎无法找出导致它的原因。通过 Capistrano 部署我的应用程序后,我通过 yui 压缩器传递所有 css,使用:
run "find #{current_path}/public/static/css/ -name '*.css' -print0 | xargs -0 -I file #{cmd} file -o file"
快速浏览和一些测试让我决定使用 Node 的 uglify-js 进行 JavaScript 压缩,所以我
uglify_bin = "uglifyjs"
run "find #{current_path}/public/static/js/ -type f -name '*.js' -print0 | xargs -0 #{uglify_bin}"
在相同的食谱。部署似乎很顺利,但快速检查我的 js 文件表明 uglifyjs 没有完成它的工作。
这是控制台输出的摘录:
* executing "find /home/USER/www/project/current/public/static/js/ -type f -name '*.js'| xargs uglifyjs --overwrite"
servers: ["project.com"]
[project.com] executing command
command finished in 127ms
我在哪里是一个十足的白痴(是的,就是这个词......)?谢谢。
I'm facing a strange issue, that surely isn't difficult, but I can't seem to find out what's causing it. After deploying my app via Capistrano, I'm passing all my css through the yui compressor, using :
run "find #{current_path}/public/static/css/ -name '*.css' -print0 | xargs -0 -I file #{cmd} file -o file"
A quick look around and a few tests made me decide to use node's uglify-js for JavaScript compression, so I went for a simple
uglify_bin = "uglifyjs"
run "find #{current_path}/public/static/js/ -type f -name '*.js' -print0 | xargs -0 #{uglify_bin}"
in the same recipe. Deployment seems to go fine, but a quick inspection at my js files shows uglifyjs didn't do it's job.
Here's an extract of the console output :
* executing "find /home/USER/www/project/current/public/static/js/ -type f -name '*.js'| xargs uglifyjs --overwrite"
servers: ["project.com"]
[project.com] executing command
command finished in 127ms
Where am I being a complete idiot (yes, it's the word...) ? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
终于找到问题所在了。这是它最终工作方式的代码行:
显然, --overwrite 选项不应该是......
Finally found what the probleme was. Here's the line of code the way it finally works :
Obviously, the --overwrite option wasn't were it should have been...
来自 uglifyjs 文档:
所以也许类似:
会起作用。
From the uglifyjs docs:
So perhaps something like:
Will work.