繁体   English   中英

rake资产:预编译不起作用

[英]rake assets:precompile not work

轨-3.2.7

ruby-2.1.0-preview1 [x86_64]

执行命令rake assets:precompile但无法获得任何响应。 当编译完成的css文件没有合并时,只看到像.right{float:right;}这样的代码

 /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. * *= require_self *= require bootstrap_and_overrides *= require nested_sortable *= require tag_it *= require jquery.lightbox-0.5 *= require morris *= require jquery.ui.datepicker *= require articles *= require messages *= require workorder *= require community *= require homepage */ /* require_tree . */ .right { float: right; } 

⇒耙资产:预编译

DEPRECATION WARNING: CarrierWave::MimeTypes is deprecated and will be removed in the future, get the content_type from the SanitizedFile object directly. (will be removed from version 0.11.0). (called from require at /Users/Saxer/.rvm/gems/ruby-2.1.0-preview1@global/gems/bundler-1.8.0/lib/bundler/runtime.rb:76)

/Users/Saxer/.rvm/rubies/ruby-2.1.0-preview1/bin/ruby /Users/Saxer/.rvm/gems/ruby-2.1.0-preview1/bin/rake assets:precompile:all RAILS_ENV = production RAILS_GROUPS = assets DEPRECATION警告:CarrierWave :: MimeTypes已弃用,将来会被删除,直接从SanitizedFile对象获取content_type。 (将从版本0.11.0中删除)。 (在/Users/Saxer/.rvm/gems/ruby-2.1.0-preview1@global/gems/bundler-1.8.0/lib/bundler/runtime.rb:76从require调用)DEPRECATION警告:CarrierWave :: MimeTypes已弃用且将来将被删除,直接从SanitizedFile对象获取content_type。 (将从版本0.11.0中删除)。 (来自/Users/Saxer/.rvm/gems/ruby-2.1.0-preview1@global/gems/bundler-1.8.0/lib/bundler/runtime.rb:76上的require)

的Gemfile

 # source 'https://rubygems.org' source 'http://ruby.taobao.org/' gem 'rails', '3.2.7' gem 'dalli', github: 'mperham/dalli' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' gem 'mysql2' gem 'memcached' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' gem 'bootstrap-sass', '~> 2.1.0.1' gem 'jquery-ui-rails' end group :development do # Haml-rails provides Haml generators for Rails 3. # Any time you generate a controller or scaffold, you'll get Haml instead of ERB templates. gem "haml-rails", ">= 0.3.4" # Annotate ActiveRecord models as a gem # USAGE # To annotate just your models: annotate --exclude tests,fixtures # To annotate routes.rb: annotate -r gem 'annotate', ">=2.5.0.pre1" gem 'pry' # gem 'debugger' gem 'pry-rails' # Mutes assets pipeline log messages. # Nothing to do, but if you want to temporarily turn on back assets' log just write: gem 'quiet_assets' gem 'wirble' gem 'hirb' gem 'pasteboaRb' gem 'awesome_print' # gem "better_errors" # gem 'letter_opener' end gem 'devise' gem "cancan" gem 'jquery-rails' gem "haml", ">= 3.1.6" gem "simple_form" gem "thin" gem 'kaminari' gem 'mini_magick' # gem 'carrierwave', :git => 'git://github.com/wjp2013/carrierwave.git' gem 'carrierwave' # https://github.com/huacnlee/carrierwave-aliyun gem 'rest-client' gem 'carrierwave-aliyun' gem 'acts-as-taggable-on', '~> 2.3.1' gem 'mercury-rails' # Nested Set is an implementation of the nested set pattern for ActiveRecord models. # https://github.com/skyeagle/nested_set gem 'nested_set', '1.7.1' gem 'bluestorm_sms', '0.0.4' # Whenever create cron jobs using Ruby, Cron is a common solution for recurring jobs. gem 'whenever', require: false gem "ckeditor", "3.7.1" # rubyzip is a ruby library for reading and writing zip files. gem 'rubyzip' # xlsx generation # https://github.com/straydogstudio/axlsx_rails gem 'axlsx_rails' gem 'fastercsv' gem 'spreadsheet' gem "nested_form" # amoeba is a ruby gem to allow the copying of ActiveRecord objects and their associated children, configurable with a DSL on the model. # https://github.com/rocksolidwebdesign/amoeba # gem 'amoeba' gem "httparty" gem 'exception_notification', :require => 'exception_notifier' # Long requests should be moved into a background process. # Delayed Job is one of the easiest ways to do this because it works with an Active Record database. # https://github.com/collectiveidea/delayed_job # http://railscasts.com/episodes/171-delayed-job-revised gem 'daemons' gem 'delayed_job_active_record' gem "delayed_job_web" gem 'china_region_fu' gem "rails3_acts_as_paranoid" # Whitelist-based Ruby HTML sanitizer. # https://github.com/rgrove/sanitize gem 'sanitize' # AutoStripAttributes gem for Rails helps to remove unnecessary whitespaces from ActiveRecord or ActiveModel attributes. # https://github.com/holli/auto_strip_attributes gem "auto_strip_attributes" gem 'best_in_place' # https://github.com/pencil/encrypted_id gem 'encrypted_id' # https://github.com/chadlwm/ip_reverse gem 'ip_reverse' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'debugger' gem 'igetui-ruby', require: 'igetui' # gem 'aliyun-mqs', github: 'wjp2013/aliyun-mqs' gem 'rake', '~> 10.1.0' 

# Compress JavaScripts and CSS
 config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

在你的production.rb文件中,请检查以上两者是否属实,然后执行并预编译。

1) rake assets:precompile只需将资源从app/assets编译为public/assets 因此,尝试删除public/assets并运行rake assets:precompile 您应该在public/assets看到已编译的资源。

2)在development环境中,Rails不提供编译资产。 它在运行时编译并分别提供所有资源。 是否意味着您在浏览器中查看application.css ,您只能看到此资源的内容。 其他资源将在其他资源中(查看HTML页面的head部分)

3)如果你想在development环境中提供来自public/assets编译资源(我不明白为什么你想要它,但没关系)你应该在config/environments/development.rb指定config.serve_static_assets = true

FYI:我建议阅读文章有关的资产管道。

环境文件中的config.server_static_assets = true将不起作用,尤其是在您使用heroku时。

我有这个问题,并尝试了很多东西。 卸载并安装宝石。 这就是诀窍:

rails assets:precompile

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM