使用Ract上的React将资产部署到生产环境

时间:2017-02-22 02:54:41

标签: ruby-on-rails reactjs deployment

我已经能够使用Procfile.static和Procfile.hot,所以我的React on Rails在我的开发环境中运行良好。由于使用Puma for React on Rails进行部署的文档很少,我尝试做我一直在做的部署:

    RAILS_ENV=production rake assets:precompile
    puma 

但是,当我运行rake资产时,我得到了这个错误:precompile:

 andy@railsapp-test:~/production/railsapp$ RAILS_ENV=production rake assets:precompile 
 cd client && npm run build:production

  railsapp-react@1.0.1 build:production /home/andy/production/railsapp/client
  NODE_ENV=production webpack --https --config webpack.config.js

 Webpack production build for Rails
 Hash: 1c2cf1a47280f63c36ac
 Version: webpack 1.14.0
 Time: 5480ms
             Asset     Size  Chunks             Chunk Names
 webpack-bundle.js  1.53 MB       0  [emitted]  main
    [0] multi main 64 bytes {0} [built]
     + 813 hidden modules
 cd client && npm run build:production

 > railsapp-react@1.0.1 build:production /home/andy/production/railsapp/client
 > NODE_ENV=production webpack --https --config webpack.config.js

 Webpack production build for Rails
 Hash: 1c2cf1a47280f63c36ac
 Version: webpack 1.14.0
 Time: 5059ms
             Asset     Size  Chunks             Chunk Names
 webpack-bundle.js  1.53 MB       0  [emitted]  main
    [0] multi main 64 bytes {0} [built]
     + 813 hidden modules
 rake aborted!
 Sass::SyntaxError: File to import not found or unreadable: app-bundle.
 Load paths:
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   /home/andy/production/railsapp/app/assets/fonts
   /home/andy/production/railsapp/app/assets/images
   /home/andy/production/railsapp/app/assets/javascripts
   /home/andy/production/railsapp/app/assets/stylesheets
   /home/andy/production/railsapp/app/assets/videos
   /home/andy/production/railsapp/app/assets/webpack
   /home/andy/production/railsapp/vendor/assets/javascripts
   /home/andy/production/railsapp/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-sass-rails-4.0.3.0/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-sass-rails-4.0.3.0/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-rails-4.1.1/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/autonumeric-rails-1.9.43/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap3-datetimepicker-rails-4.14.30/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap3-datetimepicker-rails-4.14.30/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/gmaps4rails-2.1.2/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/simple_calendar-2.1.0/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/best_in_place-3.1.0/lib/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/best_in_place-3.1.0/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/cocoon-1.2.9/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/coffee-rails-4.1.1/lib/assets/javascripts
   /home/andy/production/railsapp/app/assets/fonts
   /home/andy/production/railsapp/app/assets/videos
   /home/andy/production/railsapp/app/assets/webpack
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/fonts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/images
   /home/andy/production/railsapp/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/compass-core-1.0.3/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
   Compass::SpriteImporter
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
 (sass):9
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:67:in `rescue in import'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:45:in `import'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:28:in `imported_file'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:37:in `css_import?'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:347:in `block in _dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `block (2 levels) in each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:194:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `block in each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:346:in `grep'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:346:in `_dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:334:in `dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/compass-rails-3.0.2/lib/compass-rails/patches/sass_importer.rb:36:in `evaluate'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/tilt-2.0.2/lib/tilt/template.rb:99:in `render'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/legacy_tilt_processor.rb:25:in `call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:in `block in load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `yield'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:23:in `block in call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/utils.rb:183:in `dfs'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:24:in `call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:in `block in load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `yield'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/base.rb:66:in `find_asset'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:134:in `block in find'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:133:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:133:in `find'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:185:in `compile'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/rake/sprocketstask.rb:147:in `with_logger'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/airbrake-5.7.1/lib/airbrake/rake/task_ext.rb:19:in `execute'
 /home/andy/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
 /home/andy/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
 Sass::SyntaxError: File to import not found or unreadable: app-bundle.
 Load paths:
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   CompassRails::SpriteImporter
   /home/andy/production/railsapp/app/assets/fonts
   /home/andy/production/railsapp/app/assets/images
   /home/andy/production/railsapp/app/assets/javascripts
   /home/andy/production/railsapp/app/assets/stylesheets
   /home/andy/production/railsapp/app/assets/videos
   /home/andy/production/railsapp/app/assets/webpack
   /home/andy/production/railsapp/vendor/assets/javascripts
   /home/andy/production/railsapp/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/casein-5.1.1.5/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-sass-rails-4.0.3.0/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-sass-rails-4.0.3.0/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-4.0.3/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-rails-4.1.1/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/autonumeric-rails-1.9.43/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap3-datetimepicker-rails-4.14.30/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap3-datetimepicker-rails-4.14.30/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/gmaps4rails-2.1.2/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/simple_calendar-2.1.0/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/best_in_place-3.1.0/lib/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/best_in_place-3.1.0/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/cocoon-1.2.9/app/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/images
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/jquery-fileupload-rails-0.4.1/vendor/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/coffee-rails-4.1.1/lib/assets/javascripts
   /home/andy/production/railsapp/app/assets/fonts
   /home/andy/production/railsapp/app/assets/videos
   /home/andy/production/railsapp/app/assets/webpack
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/javascripts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/fonts
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/images
   /home/andy/production/railsapp/app/assets/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/compass-core-1.0.3/stylesheets
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
   Compass::SpriteImporter
   /home/andy/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.3/assets/stylesheets
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:65:in `import'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:28:in `imported_file'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/import_node.rb:37:in `css_import?'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:347:in `block in _dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `block (2 levels) in each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:194:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `block in each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/tree/node.rb:195:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:346:in `grep'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:346:in `_dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sass-3.4.22/lib/sass/engine.rb:334:in `dependencies'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/compass-rails-3.0.2/lib/compass-rails/patches/sass_importer.rb:36:in `evaluate'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/tilt-2.0.2/lib/tilt/template.rb:99:in `render'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/legacy_tilt_processor.rb:25:in `call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:in `block in load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `yield'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:23:in `block in call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/utils.rb:183:in `dfs'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:24:in `call'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:in `block in load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `yield'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in `load'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/base.rb:66:in `find_asset'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:134:in `block in find'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:133:in `each'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:133:in `find'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:185:in `compile'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-3.6.0/lib/rake/sprocketstask.rb:147:in `with_logger'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
 /home/andy/.rvm/gems/ruby-2.2.2/gems/airbrake-5.7.1/lib/airbrake/rake/task_ext.rb:19:in `execute'
 /home/andy/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
 /home/andy/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
 Tasks: TOP => assets:precompile
 (See full trace by running task with --trace)

所以它说有关app-bundle丢失的事情?我甚至应该编译这样的资产吗?不确定那是什么意思。这是我的反应设置:

application.html.erb

  <!-- These do not use turbolinks, so no data-turbolinks-track -->
  <!-- This is to load the hot assets.   -->
  <%= env_javascript_include_tag(hot: ['https://localhost:3500/vendor-bundle.js',
                                       'https://localhost:3500/app-bundle.js']) %>

  <!--Load react on rails hot or static libraries  -->
  <%= env_stylesheet_link_tag(static: 'application_static',
                              hot: 'application_non_webpack',
                              media: 'all',
                              'data-turbolinks-track' => false) %>
package.json
{
  "name": "railsapp-react",
  "version": "1.0.1",
  "private": true,
  "engines": {
    "node": "6.9.0",
    "npm": "4.1.1"
  },
  "scripts": {
     "start": "babel-node server-express.js",
     "build:test": "webpack --https --config webpack.config.js",
     "build:production": "NODE_ENV=production webpack --https --config webpack.production.config.js",
     "build:development": "webpack -w --https --config webpack.config.js",
     "hot-assets": "babel-node server-rails-hot.js",
     "build:server": "webpack --config webpack.server.rails.build.config.js",
     "build:dev:server": "webpack -w --https --config webpack.server.rails.build.config.js",
     "build:dev:client": "webpack -w --https --config webpack.client.rails.build.config.js"
  },
  "cacheDirectories": ["node_modules", "client/node_modules"],
  "dependencies": {
    "jquery": "^3.1.1",
    "jquery-ujs": "^1.2.2",
    "loader-utils": "^0.2.16",
    "autoprefixer": "^6.5.3",
     "axios": "^0.15.2",
     "actioncable": "^5.0.1",
      "classnames": "^2.2.5",
      "css-loader": "^0.26.0",
      "babel-cli": "^6.18.0",
      "babel-core": "^6.21.0",
      "babel-loader": "^6.2.10",
      "babel-runtime": "^6.20.0",
      "babel-polyfill": "^6.20.0",
      "babel-preset-es2015": "^6.18.0",
      "babel-preset-react": "^6.16.0",
      "babel-preset-stage-0": "^6.16.0",
      "bootstrap-loader": "^1.3.0",
      "bootstrap-sass": "^3.3.7",
      "es5-shim": "^4.5.9",
      "expose-loader": "^0.7.1",
      "extract-text-webpack-plugin": "^1.0.1",
      "file-loader": "^0.9.0",
      "immutable": "^3.8.1",
      "imports-loader": "^0.6.5",
      "lodash": "^4.17.2",
       "marked": "^0.3.6",
      "node-sass": "^3.13.0",
      "node-uuid": "^1.4.7",
    "react-addons-css-transition-group": "^15.4.1",
    "postcss-loader": "^1.1.1",
    "imports-loader": "^0.7.0",
    "react": "^15.4.1",
    "react-bootstrap": "^0.30.7",
      "react-bootstrap-table": "2.11.2",
    "react-dom": "^15.4.1",
    "react-on-rails": "6.5.1",
    "react-redux": "^4.4.6",
    "react-router": "^3.0.0",
      "react-router-redux": "^4.0.7",
    "redux": "^3.6.0",
    "redux-thunk": "^2.1.0",
    "resolve-url-loader": "^1.6.0",
    "sass-loader": "^4.0.2",
    "sass-resources-loader": "1.1.0",
    "style-loader": "^0.13.1",
    "turbolinks": "^5.0.0",
    "url-loader": "^0.5.7",
    "webpack": "^1.14.0"



  },

  "devDependencies": {
    "babel-eslint": "^7.1.1",
    "babel-plugin-react-transform": "^2.0.2",
    "body-parser": "^1.15.2",
    "chai": "^3.5.0",
    "chai-immutable": "^1.6.0",
    "eslint": "^3.10.2",
    "eslint-config-shakacode": "^13.2.0-beta.1",
    "eslint-import-resolver-webpack": "^0.7.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-react": "^6.7.1",
    "estraverse-fb": "^1.3.1",
    "express": "^4.14.0",
    "jsdom": "^9.8.3",
    "mocha": "^3.1.2",
    "pug": "^2.0.0-beta6",
    "react-addons-test-utils": "^15.4.1",
    "react-transform-hmr": "^1.0.4",
    "sleep": "^5.0.0",
    "webpack-dev-server": "^1.16.2"
  }
}
webpack.production.config.js

const webpack = require('webpack');
const path = require('path');

const devBuild = process.env.NODE_ENV !== 'production';
const nodeEnv = devBuild ? 'development' : 'production';

const config = {
  entry: [
    'es5-shim/es5-shim',
    'es5-shim/es5-sham',
    'babel-polyfill',
  //  './app/bundles/dashboard/startup/registration',
  ],

  output: {
    filename: 'webpack-bundle.js',
    path: '../app/assets/webpack',
  },

  resolve: {
    extensions: ['', '.js', '.jsx'],
    alias: {
      react: path.resolve('./node_modules/react'),
      'react-dom': path.resolve('./node_modules/react-dom'),
    },
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify(nodeEnv),
      },
    }),
  ],
  module: {
    loaders: [
      {
        test: require.resolve('react'),
        loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham',
      },
      {
        test: /\.jsx?$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
      },
    ],
  },
};

module.exports = config;

if (devBuild) {
  console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
  module.exports.devtool = 'eval-source-map';
} else {
  config.plugins.push(
    new webpack.optimize.DedupePlugin()
  );
  console.log('Webpack production build for Rails'); // eslint-disable-line no-console
}

我假设必须有一些其他的方法来编译资产只是使用React包并在我的application.html.erb中提供一些奇怪的方式吗?我真的甚至不知道在这一点上尝试什么!

感谢您提供的任何帮助

1 个答案:

答案 0 :(得分:0)

我得到了它的工作!现在资产编译得很好,而puma正确地为他们服务。我必须像这样设置我的package.json“脚本”:

     "scripts": {
     "start": "babel-node server-express.js",
     "build:test": "webpack --https --config webpack.config.js",
     "build:production": "NODE_ENV=production webpack --https --config webpack.client.rails.build.config.js",
     "build:development": "webpack -w --https --config webpack.config.js",
     "hot-assets": "babel-node server-rails-hot.js",
     "build:server": "webpack --config webpack.server.rails.build.config.js",
     "build:dev:server": "webpack -w --https --config webpack.server.rails.build.config.js",
     "build:dev:client": "webpack -w --https --config webpack.client.rails.build.config.js"
  },

然后我必须将以下内容添加到application.html.erb中,以便静态js加载:

 <!-- These do use turbolinks -->
<%= env_javascript_include_tag(static: 'application_static',
                             hot: 'application_non_webpack',
                              'data-turbolinks-track' => false) %>

现在我只是遇到Jquery没有被加载(或者没有被加载)的问题,但我很高兴能够超越那座山!