Sha256: 13109c65c2d1df97b45e9cd1f022a058fed234e08843db18953dff6c6eabe854

Contents?: true

Size: 1.78 KB

Versions: 12

Compression:

Stored size: 1.78 KB

Contents

require "yaml"

module BrowserifyRails
  class Railtie < Rails::Engine
    config.browserify_rails = ActiveSupport::OrderedOptions.new

    # Browserify every file if true. Can be a proc.
    config.browserify_rails.force = false

    # Which paths should be browserified?
    config.browserify_rails.paths = [lambda { |p| p.start_with?(Rails.root.join("app").to_s) },
                                     lambda { |p| p.start_with?(Rails.root.join("node_modules").to_s) }]

    config.browserify_rails.node_bin = "node_modules/.bin/"

    # Should node_modules be evaluated assets before run_browserify
    config.browserify_rails.evaluate_node_modules = false

    # Environments to generate source maps in
    config.browserify_rails.source_map_environments = []

    # Use browserifyinc instead of browserify
    # TODO figure out how to handle module paths being in output
    # until then, disable in staging and production
    config.browserify_rails.use_browserifyinc = !["staging", "production"].include?(Rails.env)

    if config.respond_to?(:assets)
      config.assets.configure do |env|
        load_granular_configuration
        env.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
      end
    else
      initializer :setup_browserify do |app|
        load_granular_configuration
        app.assets.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
      end
    end


    rake_tasks do
      Dir[File.join(File.dirname(__FILE__), "tasks/*.rake")].each { |f| load f }
    end

    def load_granular_configuration
      filename = File.join(Rails.root, 'config', 'browserify.yml')
      configuration = YAML::load(File.read(filename)) if File.exist? filename
      config.browserify_rails.granular = configuration || {}
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
browserify-rails-3.4.0 lib/browserify-rails/railtie.rb
browserify-rails-3.3.0 lib/browserify-rails/railtie.rb
browserify-rails-3.2.0 lib/browserify-rails/railtie.rb
browserify-rails-3.1.0 lib/browserify-rails/railtie.rb
browserify-rails-3.0.1 lib/browserify-rails/railtie.rb
browserify-rails-3.0.0 lib/browserify-rails/railtie.rb
browserify-rails-2.2.1 lib/browserify-rails/railtie.rb
browserify-rails-2.2.0 lib/browserify-rails/railtie.rb
browserify-rails-2.1.0 lib/browserify-rails/railtie.rb
browserify-rails-2.0.3 lib/browserify-rails/railtie.rb
browserify-rails-2.0.2 lib/browserify-rails/railtie.rb
browserify-rails-1.5.0 lib/browserify-rails/railtie.rb