Django 和 CoffeeScript 到 Heroku 的奇怪部署问题
这是一个复杂的问题,因此需要一些时间来解释。我不是在寻找直接答案,所以任何建议都会很好。我有一个 Django 应用程序,它使用了大量的 CoffeeScript。为了在项目中编译 CoffeeScript,我使用了应用程序 django-compressor。要使用 django-compressor 我需要安装 nmp (节点包管理器)。不幸的是,我无法在 Heroku 上安装 npm
。因此,我需要在 CoffeeScript 到达 Heroku 服务器之前对其进行编译。因此,我通过设置 Fabric
来做到这一点,它似乎运行良好。
我遇到了问题,因为我可以将编译后的 CoffeeScript 作为静态文件获取,但模板中仍然具有 {% compress js %} *** {% endcompress %}
标签,因为 < code>django-compressor 在运行时之前不会重新生成新模板。
因此,我正在寻找有关如何部署应用程序以使用模板标签的建议,以便可以将应用程序部署在 Heroku 上。我知道这是一个包含很多部分的问题,所以任何建议都会非常有帮助!
This is sort of a complex question so it will take a bit to explain. I'm not looking for a direct answer so any advice would be good. I have a Django app that uses a lot of CoffeeScript. To compile the CoffeeScript in the project I am using the app django-compressor
. To use django-compressor
I need to install nmp
(node package manager). Unfortunately, I can't install npm
on Heroku. Thus, I need to compile the CoffeeScript before it hits the Heroku servers. So I did that by setting up Fabric
which is seeming to work well.
I am running into a problem no because I can get the compiled CoffeeScript as a static file but the templates still have the {% compress js %} *** {% endcompress %}
tags in them because django-compressor
does not regenerate new templates until run time.
Thus I am looking for advice on how to deploy the app to get ride of the template tags so that the app can be deployed on Heroku. I know it is a question with a lot of parts so any piece of advice would be super helpful!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到这是一个很老的问题 - 偶尔会碰到它
以防万一,处理方法如下:
http://django_compressor.readthedocs。 org/en/latest/usage/#pre-compression
http://django_compressor.readthedocs.org/en/latest/scenarios/#offline-compression
I realize it's quite an old question - hit it occasionally
Just in case, here's the way to deal:
http://django_compressor.readthedocs.org/en/latest/usage/#pre-compression
http://django_compressor.readthedocs.org/en/latest/scenarios/#offline-compression
您还可以提交 django 压缩器生成的 manifest.json 文件(我假设您在离线模式下使用它),然后它会知道哪些模板块转到哪些已编译的 js/css 文件
you could also commit the manifest.json file that django compressor generates (I'm assuming you're using it in offline mode) and then it will know which template blocks go to which compiled js/css files