Sha256: 4f33fa8b0341cbad18d3bf35d5b9e385e2bf506fca0157b9a9a6f77b385cd095

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module React
  module Rails
    # This class accepts some options for which build you want, then exposes where you can find
    # them. In general, these paths should be added to the sprockets environment.
    class AssetVariant
      GEM_ROOT = Pathname.new("../../../../").expand_path(__FILE__)
      # @return [String] "production" or "development"
      attr_reader :react_build

      # @return [String] The path which contains the specified React.js build as "react.js"
      attr_reader :react_directory

      # @return [String] The path which contains the JSX Transformer
      attr_reader :jsx_directory

      # @param [Hash] Options for the asset variant
      # @option variant [Symbol] if `:production`, use the minified React.js build
      def initialize(options = {})
        @react_build = options[:variant] == :production ? "production" : "development"

        @react_directory = GEM_ROOT.join("lib/assets/react-source/").join(@react_build).to_s
        @jsx_directory =   GEM_ROOT.join("lib/assets/javascripts/").to_s
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
react-rails-3.2.0 lib/react/rails/asset_variant.rb
react-rails-3.1.1 lib/react/rails/asset_variant.rb
react-rails-3.1.0 lib/react/rails/asset_variant.rb
react-rails-3.0.0 lib/react/rails/asset_variant.rb
react-rails-3.0.0.rc.0 lib/react/rails/asset_variant.rb