Sha256: eedf4ef9f925c8b0847ca5431b62a1b81bbfb4d64346f311e718a7565fcb0161

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

require "yaml"

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

    # Always browserify every file
    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)

    initializer :setup_browserify do |app|
      # 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 || {}

      app.assets.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
browserify-rails-1.4.0 lib/browserify-rails/railtie.rb
browserify-rails-1.3.0 lib/browserify-rails/railtie.rb
browserify-rails-1.2.0 lib/browserify-rails/railtie.rb
browserify-rails-1.1.0 lib/browserify-rails/railtie.rb
browserify-rails-1.0.2 lib/browserify-rails/railtie.rb
browserify-rails-1.0.1 lib/browserify-rails/railtie.rb
browserify-rails-1.0.0 lib/browserify-rails/railtie.rb
browserify-rails-1.0.0b lib/browserify-rails/railtie.rb