有人可以解释如何将Yii最小化资产应用于Heroku吗? [英] Can someone explain how Yii minimizing assets is supposed to work on Heroku?

查看:100
本文介绍了有人可以解释如何将Yii最小化资产应用于Heroku吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚获得了缩小版本的使用权(

I just got through getting the minification to work (How do I combine & minify JS and CSS for a Yii app on Heroku?) locally. However, it creates the all-1bc649be34b1e6afc9b2419687cde016.js file under web/assets/. Yii creates a .gitignore to ignore everything in that directory. None of the files will make it to Heroku. Even if I use heroku run yii asset assets.php config/assets-prod.php it will only create ephemeral files that are not accessible to the web dynos. (As suspected it does fail in production. The CSS is not there!) How does minification work with Heroku? What happens if I change a file? Do I have to manually run the assets command again? Is there a way to make it automatic?

推荐答案

好吧,我在Heroku文档中找到了这个宝石. https://devcenter.heroku.com/articles/php-support#custom -compile-step .事实证明,有一种方法可以在Composer的composer.json中指定一个命令,以便在slug编译期间运行.所以我加了

Ok I found this gem in Heroku docs. https://devcenter.heroku.com/articles/php-support#custom-compile-step. Turns out there is a way to specify a command in Composer's composer.json to run during the slug compilation. So I added

"scripts": {
    "compile": "php yii asset assets.php config/assets-prod.php"

并部署,它会自动生成缩小的资产! ew!这个f -----大约花了10个小时才能开始工作-远远超出了应有的时间!

and deployed and it generated the minified assets automatically! Whew! This f----- took like 10 hours to get working - way more than it should have!

哦,我可能应该提到我也必须破解config/console.php才能使yii命令在Heroku上运行,因为它给出了有关Gii的错误.

Oh I should probably mention I had to hack config/console.php also to get the yii command to run on Heroku, because it gives an error about Gii.

'bootstrap' => YII_ENV == 'dev' ? ['log', 'gii'] : ['log'],
'modules' => YII_ENV == 'dev' ? [
  'gii' => 'yii\gii\Module'
] : [],

这篇关于有人可以解释如何将Yii最小化资产应用于Heroku吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆