javascript-Twitter引导jquery插件未针对生产进行编译 [英] javascript - Twitter bootstrap jquery plugins not compiled for production
问题描述
我正在使用 seyhunak的宝石和Twitter Bootstrap开发一个3.1 Rails应用.
I'm developing a 3.1 Rails app with Twitter Bootstrap using seyhunak's gem.
在生产模式下,我能够通过管道预编译使用基本的引导CSS和JS:
On the production mode, I was able to use basic bootstrap CSS and JS through pipeline precompilation:
RAILS_ENV=production bundle exec rake assets:precompile
使用gem文件:
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem "twitter-bootstrap-rails"
end
还有application.js文件:
And the application.js file:
//= require_tree .
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require bootstrap-tab
//= require bootstrap-modal
//= require bootstrap-dropdown
//= require bootstrap-popover
除了引导插件(如模式和下拉列表)外,该应用程序运行正常.这些插件以静态javascript库的形式存在于供应商资产目录中:
The application worked fine except for for the bootstrap plugins such as modals and dropdowns. These plugins exist as static javascript libraries existing inside the vendor assets directory:
/vendor/assets/javascripts/bootstrap-dropdown.js
...
我不确定这些文件是否已被预编译,如何管理?
I'm not sure whether these files are being precompiled or not, how can I manage to do so?
推荐答案
找到了!
这不是引导程序的问题,而是正确地预编译jQuery的问题.以及无需为单个插件包含javascript文件.它们已经包含在主要的twitter/bootstrap中.
It wasn't a problem of bootstrap, but rather with properly precompiling jQuery. As well as there is no need for including the javascript files for individual plugins. They are already included in the main twitter/bootstrap.
问题通过如下重新排列javascripts文件来解决:
Problem was solved by re-arranging the javascripts files as follows:
application.js
application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
宝石文件
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem "twitter-bootstrap-rails"
end
gem 'jquery-rails', '>= 1.0.12'
预编译资产并正常工作!
Precompling the assets and worked!
这篇关于javascript-Twitter引导jquery插件未针对生产进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!