Class: JsRoutes::Generators::Webpacker

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

Instance Method Summary collapse

Instance Method Details

#create_webpackObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/js_routes/generators/webpacker.rb', line 7

def create_webpack
  copy_file "initializer.rb", "config/initializers/js_routes.rb"
  copy_file "erb.js", "config/webpack/loaders/erb.js"
  copy_file "routes.js.erb", "#{Webpacker.config.source_path}/routes.js.erb"
  inject_into_file "config/webpack/environment.js", loader_content
  if path = application_js_path
    inject_into_file path, pack_content
  end
  command = Rails.root.join("./bin/yarn add rails-erb-loader")
  run command
end