ElMassimo / ElMassimo/vite_ruby

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

Open
#525 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Ruby
Stars
1.6k
Forks
149
Avg merge
5h 13m
Merged PRs (30d)
2

Description

**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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.