爲什麼Rails4放棄了對Gemfile中“assets”組的支持 - Why did Rails4 drop support for “assets” group in the Gemfile

問題:

In Rails 3, gems used exclusively to generate assets in the asset pipeline were properly placed in the assets group of the Gemfile: 在Rails 3中,專門用於在資產管道中生成資產的gem被正確放置在Gemfile的assets組中:

...

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
end

Now, according to the (still in progress) upgrade documentation : 現在,根據(仍在進行中) 升級文檔

Rails 4.0 removed the assets group from Gemfile. Rails 4.0從Gemfile中刪除了資產組。 You'd need to remove that line from your Gemfile when upgrading. 升級時,您需要從Gemfile中刪除該行。

Sure enough, making a new project with RC1 yields a Gemfile with asset-related gems included by default outside of any group: 果然,使用RC1創建一個新項目會產生一個Gemfile,其默認包含在任何組之外的與資產相關的gems:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc1'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc1'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

...

Does this mean these gems will now be bundled in production builds by default? 這是否意味着這些寶石現在默認捆綁在生產版本中? If so, why the change of heart? 如果是這樣,爲什麼改變心意? Is Rails 4 moving towards the dynamic generation of assets in production? Rails 4是否正朝着生產中動態生成資產的方向發展?


解決方案:

參考: https://stackoom.com/en/question/16q0C
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章