为什么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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章