Capistrano 部署后 uglify-js 挂钩输出但不写入文件

发布于 2024-11-27 08:01:04 字数 779 浏览 2 评论 0原文

我面临着一个奇怪的问题,这肯定不难,但我似乎无法找出导致它的原因。通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

翻身的咸鱼 2024-12-04 08:01:04

终于找到问题所在了。这是它最终工作方式的代码行:

run "find #{current_path}/public/static/js/ -name '*.js'| xargs -I file #{uglify_path} --overwrite file"

显然, --overwrite 选项不应该是......

Finally found what the probleme was. Here's the line of code the way it finally works :

run "find #{current_path}/public/static/js/ -name '*.js'| xargs -I file #{uglify_path} --overwrite file"

Obviously, the --overwrite option wasn't were it should have been...

著墨染雨君画夕 2024-12-04 08:01:04

来自 uglifyjs 文档

--overwrite — 如果代码是从文件(而不是 STDIN)读取的,并且您传递 --overwrite 那么输出将写入同一个文件中。

所以也许类似:

uglify_bin = "uglifyjs"
run "find #{current_path}/public/static/js/ -type f -name '*.js' -print0 | xargs -0 #{uglify_bin} --overwrite"

会起作用。

From the uglifyjs docs:

--overwrite — if the code is read from a file (not from STDIN) and you pass --overwrite then the output will be written in the same file.

So perhaps something like:

uglify_bin = "uglifyjs"
run "find #{current_path}/public/static/js/ -type f -name '*.js' -print0 | xargs -0 #{uglify_bin} --overwrite"

Will work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文