Sha256: 3c6c79b7e8f962d2fb705bb516e5f2c627c0086963cb325db62b24770ce19c59
Contents?: true
Size: 908 Bytes
Versions: 1
Compression:
Stored size: 908 Bytes
Contents
require "rails/generators" class JsRoutes::Generators::Middleware < Rails::Generators::Base source_root File.expand_path(__FILE__ + "/../../../templates") def create_middleware copy_file "initializer.rb", "config/initializers/js_routes.rb" # copy_file "erb.js", "config/webpack/loaders/erb.js" # copy_file "routes.js.erb", "app/javascript/routes.js.erb" # inject_into_file "config/webpack/environment.js", loader_content inject_into_file "app/javascript/packs/application.js", pack_content inject_into_file "config/environments/development.rb", middleware_content, before: /^end\n\z/ end protected def pack_content <<-JS import * as Routes from '../routes'; window.Routes = Routes; JS end def middleware_content <<-RB # Automatically update routes.js file # when routes.rb is changed config.middleware.use(JsRoutes::Middleware) RB end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
js-routes-2.2.0 | lib/js_routes/generators/middleware.rb |