-
Notifications
You must be signed in to change notification settings - Fork 756
/
Copy pathasset_variant.rb
27 lines (22 loc) · 1.04 KB
/
asset_variant.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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