问题描述
所以,我刚才意识到我完全不知道Sprockets在rails中是什么。
So, I just realised that I have absolutely no Idea what Sprockets are in rails.
当使用bootstrap或者实现时,要求包含 sprocket
(bootstrap-sprocket或materialize-sprocket)在 application.js
文件中。
when using either bootstrap, or materialize, it is requested to include the sprocket
(bootstrap-sprocket or materialize-sprocket) in the application.js
file.
我搜索的所有内容都谈到资产管道并让我感到困惑。
Everything I search talks about the asset pipeline and confuses me the more.
根据ruby-guides,
According to ruby-guides,
当我做捆绑show sprockets-rails
时,我得到了:
/Users/Sunday/workspace/resilience/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.1
表明我至少有宝石。
但是我的困惑和我的问题是 sprockets的重要性是什么
,而不是 sprockets-rails
,这使得其他宝石像 bootstrap
和具体化
,可能还有其他人有 sprockets
,特别是在他们的javascript文件中?
But my confusion and my question is that what is the importance of sprockets
, as opposed to sprockets-rails
that made other gems like bootstrap
and materialize
and probably some others to have sprockets
, especially in their javascript files?
谢谢。
推荐答案
Sprockets是一个用于编译和提供Web资产的Ruby库。 Sprockets允许将应用程序的JavaScript文件组织成更小,更易于管理的块,这些块可以分布在多个目录和文件中。它提供了有关如何在我们的项目中包含资产的结构和实践。
Sprockets is a Ruby library for compiling and serving web assets. Sprockets allows to organize an application’s JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files. It provides structure and practices on how to include assets in our projects.
在每个JavaScript文件的开头使用指令,Sprockets可以确定JavaScript文件所依赖的文件。在部署应用程序时,Sprockets然后使用这些指令将您的多个JavaScript文件转换为单个文件,以获得更好的性能。
Using directives at the start of each JavaScript file, Sprockets can determine which files a JavaScript file depends on. When it comes to deploying your application, Sprockets then uses these directives to turn your multiple JavaScript files into a single file for better performance.
这篇关于链轮中的链轮意味着什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!