Rails 何时编译 CoffeeScript?
Rails 何时将 Coffeescript 资源编译为 JavaScript?它是按需发生还是在启动时发生?
When does Rails compile Coffeescript resources to JavaScript? Does it happen on-demand or at startup?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当向包含 CoffeeScript 资源的视图发出请求时,CoffeeScript 会按需编译为 JavaScript。
但是,您可以使用以下命令提前将 CoffeeScript 编译为 JavaScript:
请参阅此链接了解有关 Rails 资产管道的更多信息。
从链接:
...
...
UPDATE:
对于那些对预编译开发资源感兴趣的人,请首先将 RAILS_ENV 变量设置为开发(来自 在这里):
CoffeeScript compiles to JavaScript on demand when a request is made to a view that includes a CoffeeScript resource.
However, you can use the following to have CoffeeScript compile to JavaScript ahead of time:
See this link for more information on the Rails asset pipeline.
From the link:
...
...
UPDATE:
For those interested in precompiling assets for development, set the RAILS_ENV variable to development first (from here):