Sha256: bfcf55fc731e1bbb38f0050839315a923bf70398092962ef09936d67b33603ad
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require 'vite_rails_legacy' # Internal: Extends the base installation script from Vite Ruby to work for a # typical Rails app. module ViteRailsLegacy::Installation RAILS_TEMPLATES = Pathname.new(File.expand_path('../../templates', __dir__)) # Override: Setup a typical apps/web Hanami app to use Vite. def setup_app_files cp RAILS_TEMPLATES.join('config/rails-vite.json'), config.config_path if root.join('app/javascript').exist? Dry::CLI::Utils::Files.replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "app/javascript",) end end # Override: Create a sample JS file and attempt to inject it in an HTML template. def install_sample_files unless config.resolved_entrypoints_dir.join('application.js').exist? cp RAILS_TEMPLATES.join('entrypoints/application.js'), config.resolved_entrypoints_dir.join('application.js') end if (layout_file = root.join('app/views/layouts/application.html.erb')).exist? inject_line_before layout_file, '</head>', <<-HTML <%= vite_client_tag %> <%= vite_javascript_tag 'application' %> HTML end end end ViteRuby::CLI::Install.prepend(ViteRailsLegacy::Installation)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vite_rails_legacy-2.0.4 | lib/vite_rails_legacy/installation.rb |
vite_rails_legacy-2.0.3 | lib/vite_rails_legacy/installation.rb |
vite_rails_legacy-2.0.2 | lib/vite_rails_legacy/installation.rb |