vite_ruby icon indicating copy to clipboard operation
vite_ruby copied to clipboard

ViteRuby: Add configuration in config/vite.rb for running proxy in custom environments

Open vizo opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. We use Rails custom environments e.g. staging, unit_test, ... Since run_proxy? has hardcoded env names and logic, it would be great to make run_proxy? configurable as lambda that returns true/false in config/vite.rb.

Additional context Source code: https://github.com/ElMassimo/vite_ruby/blob/dcdfbbac972b6ba867ed5a6e1263c8f30268f577/vite_ruby/lib/vite_ruby.rb#L109

For now i had to monkey patch:

    # Public: The proxy for assets should not run in production mode or test mode when env CI is present.
    def run_proxy?
      return false if config.mode == "production"
      return false if config.mode.ends_with?("test") && ENV.fetch("CI", false)

      true
    rescue StandardError => e
      logger.error("Failed to check mode for Vite: #{e.message}")
      false
    end

vizo avatar Jan 07 '25 10:01 vizo