Class: ReactWebpackRails::RWRViewHelpers::ImagePaths
- Inherits:
-
Object
- Object
- ReactWebpackRails::RWRViewHelpers::ImagePaths
- Defined in:
- lib/react_webpack_rails/rwr_view_helpers/image_paths.rb
Class Attribute Summary collapse
-
.include ⇒ Object
Returns the value of attribute include.
Class Method Summary collapse
Class Attribute Details
.include ⇒ Object
Returns the value of attribute include.
5 6 7 |
# File 'lib/react_webpack_rails/rwr_view_helpers/image_paths.rb', line 5 def include @include end |
Class Method Details
.fetch ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/react_webpack_rails/rwr_view_helpers/image_paths.rb', line 10 def self.fetch project_assets = {} env = Sprockets::Railtie.build_environment(::Rails.application) env.logical_paths do |logical_path, filename| next unless @include.any? { |wildcard| File.fnmatch(wildcard.to_s, logical_path) } assets_root = ::Rails.application.config.action_controller.asset_host.present? \ ? ::Rails.application.config.action_controller.asset_host \ : '/' project_assets[logical_path] = File.join( assets_root, ::Rails.application.config.assets.prefix, env.file_digest(filename) ? env[logical_path].digest_path : logical_path ) end Dir.mkdir(::Rails.root.join('tmp', 'cache')) unless File.exists?(::Rails.root.join('tmp', 'cache')) open(::Rails.root.join('tmp', 'cache', 'assets-mapping.json'), 'w') do |file| file.write project_assets.to_json end return project_assets end |