Class: ReactWebpackRails::Install::CoreGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/react_webpack_rails/install/core_generator.rb

Instance Method Summary collapse

Instance Method Details

#baseObject



13
14
15
16
17
18
# File 'lib/generators/react_webpack_rails/install/core_generator.rb', line 13

def base
  copy_file '.babelrc', '.babelrc'
  create_file 'app/assets/javascripts/react_bundle.js'
  require_bundles_in_application_js
  template 'react/index.js', 'app/react/index.js'
end

#gitignoreObject



24
25
26
27
28
29
30
31
# File 'lib/generators/react_webpack_rails/install/core_generator.rb', line 24

def gitignore
  append_file '.gitignore' do <<-'TEXT'.strip_heredoc
    /node_modules
    /app/assets/javascripts/react_bundle.js
    /app/assets/stylesheets/react_bundle.css
    TEXT
  end
end

#packageObject



33
34
35
36
37
38
39
# File 'lib/generators/react_webpack_rails/install/core_generator.rb', line 33

def package
  if options.tmp_package
    copy_file 'packages/core.json', 'tmp/package.json', force: true
  else
    copy_file 'packages/core.json', 'package.json'
  end
end

#structureObject



20
21
22
# File 'lib/generators/react_webpack_rails/install/core_generator.rb', line 20

def structure
  create_file 'app/react/components/.keep'
end

#webpackObject



41
42
43
44
45
# File 'lib/generators/react_webpack_rails/install/core_generator.rb', line 41

def webpack
  copy_file 'webpack.config.js', 'webpack.config.js'
  copy_file 'webpack/dev.config.js', 'webpack/dev.config.js'
  copy_file 'webpack/production.config.js', 'webpack/production.config.js'
end