Sha256: 5c03703d0c13d10f9ecfec8dd4b19c3a6df15f1b60c56cbdcc70a5e3008778c2

Contents?: true

Size: 902 Bytes

Versions: 1

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

class ViteRuby::CLI::SSR < ViteRuby::CLI::Vite
  DEFAULT_ENV = CURRENT_ENV || 'production'
  JS_EXTENSIONS = %w[js mjs cjs]

  desc 'Run the resulting app from building in SSR mode.'
  executable_options

  def call(mode:, inspect: false, trace_deprecation: false)
    ViteRuby.env['VITE_RUBY_MODE'] = mode

    ssr_entrypoint = JS_EXTENSIONS
      .map { |ext| ViteRuby.config.ssr_output_dir.join("ssr.#{ ext }") }
      .find(&:exist?)

    unless ssr_entrypoint
      raise ArgumentError, "No ssr entrypoint found `#{ ViteRuby.config.ssr_output_dir.relative_path_from(ViteRuby.config.root) }/ssr.{#{ JS_EXTENSIONS.join(',') }}`. Have you run bin/vite build --ssr?"
    end

    cmd = [
      'node',
      ('--inspect-brk' if inspect),
      ('--trace-deprecation' if trace_deprecation),
      ssr_entrypoint,
    ]
    Kernel.exec(*cmd.compact.map(&:to_s))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vite_ruby-3.2.0.beta0 lib/vite_ruby/cli/ssr.rb