Sha256: 2c8c750bf92d579ceb0cd89350092d9a7b4e10efcfb987d07e334c54427ebc79

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

require 'sprockets'
require_relative './task'

# reopen Sprockets::Index and monkeypatch find_asset
class Sprockets::Index
  original_find_asset = instance_method(:find_asset)

  define_method :find_asset, ->(path, options = {}) {
    unless @_webpack_built
      WebpackRails::Task.run_webpack # ensure output files exist so original_find_asset doesn't fail
      @_webpack_built = true
    end
    original_find_asset.bind(self).(path, options)
  }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webpack_rails-0.3.0 lib/webpack_rails/sprockets_index_webpack.rb
webpack_rails-0.2.0 lib/webpack_rails/sprockets_index_webpack.rb
webpack_rails-0.1.0 lib/webpack_rails/sprockets_index_webpack.rb