Class: Webpack::ConfigGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/webpack/config_generator.rb

Instance Method Summary collapse

Instance Method Details

#change_rails_contextObject



5
6
7
# File 'lib/generators/webpack/config_generator.rb', line 5

def change_rails_context
  gsub_file 'Rakefile', 'require File.expand_path(\'../config/application\', __FILE__)', 'require_relative \'config/environment\''
end

#init_configObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/webpack/config_generator.rb', line 9

def init_config
  copy_file 'files/webpack.rb', 'config/initializers/webpack.rb'
  if File.exist? Rails.root.join('config', 'webpack.yml')
    log :skipped, 'config/webpack.yml'
  else
    template 'templates/webpack.yml.erb', 'config/webpack.yml' 
  end

  puts 'Ready for webpack! Configure with config/webpack.yml.'
end