Sha256: 408c325e86d9b0b98b5036e8e6b4406423dfa728ca9a5d49f797a9ff23b6e4c4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

# Install Vite Rails
say 'Creating configuration files'
copy_file "#{ __dir__ }/config/vite.json", ViteRails.config.config_path
copy_file "#{ __dir__ }/config/vite.config.ts", Rails.root.join('vite.config.ts')

say 'Creating entrypoints directory'
directory "#{ __dir__ }/javascript/entrypoints", ViteRails.config.resolved_entrypoints_dir

apply "#{ __dir__ }/binstubs.rb"

git_ignore_path = Rails.root.join('.gitignore')
if git_ignore_path.exist?
  append_to_file(git_ignore_path) {
    <<~GITIGNORE

      # Vite on Rails
      /public/vite
      /public/vite-dev
      /public/vite-test
      node_modules
      *.local
      .DS_Store
    GITIGNORE
  }
end

Dir.chdir(Rails.root) do
  say 'Installing JavaScript dependencies for Vite Rails'
  package_json = File.read("#{ __dir__ }/../../package.json")

  vite_version = package_json.match(/"vite": "(.*)"/)[1]
  plugin_version = package_json.match(/"vite-plugin-ruby": "(.*)"/)[1]

  say 'Installing vite as direct dependencies'
  run "yarn add vite@#{ vite_version } vite-plugin-ruby@#{ plugin_version }"
end

say 'Vite ⚡️ Rails successfully installed! 🎉', :green

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vite_rails-1.0.10 lib/install/template.rb
vite_rails-1.0.9 lib/install/template.rb