Sha256: 937008454c3d27f4edfca97771e8781ce2e6c6b9d6583ffc17379d2311814394

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require "webpacker/configuration"

babelrc = Rails.root.join(".babelrc")

if File.exist?(babelrc)
  react_babelrc = JSON.parse(File.read(babelrc))
  react_babelrc["presets"] ||= []

  unless react_babelrc["presets"].include?("react")
    react_babelrc["presets"].push("react")
    say "Copying react preset to your .babelrc file"

    File.open(babelrc, "w") do |f|
      f.puts JSON.pretty_generate(react_babelrc)
    end
  end
else
  say "Copying .babelrc to app root directory"
  copy_file "#{__dir__}/examples/react/.babelrc", ".babelrc"
end

say "Copying react example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx"

say "Updating webpack paths to include .jsx file extension"
insert_into_file Webpacker.config.config_path, "    - .jsx\n", after: /extensions:\n/

say "Installing all react dependencies"
run "yarn add react react-dom babel-preset-react prop-types"

say "Webpacker now supports react.js 🎉", :green

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
webpacker-3.6.0 lib/install/react.rb
webpacker-3.5.5 lib/install/react.rb
webpacker-3.5.3 lib/install/react.rb
webpacker-3.5.2 lib/install/react.rb
webpacker-3.5.1 lib/install/react.rb
webpacker-3.5.0 lib/install/react.rb
webpacker-3.4.3 lib/install/react.rb
webpacker-4.0.0.pre.pre.2 lib/install/react.rb
webpacker-4.0.0.pre.pre.1 lib/install/react.rb
webpacker-3.4.1 lib/install/react.rb
webpacker-3.4.0 lib/install/react.rb
webpacker-3.3.1 lib/install/react.rb
webpacker-3.3.0 lib/install/react.rb
webpacker-3.2.2 lib/install/react.rb
webpacker-3.2.1 lib/install/react.rb