lib/vite_ruby/config.rb in vite_ruby-3.0.5 vs lib/vite_ruby/config.rb in vite_ruby-3.0.6
- old
+ new
@@ -41,10 +41,16 @@
# Public: The directory that Vite uses as root.
def vite_root_dir
root.join(source_code_dir)
end
+ # Public: Loads an optional config/vite.rb file that can modify ViteRuby.env
+ def load_ruby_config
+ rb_config_path = File.expand_path(config_path.sub(/.json$/, '.rb'), root)
+ load rb_config_path if File.exist?(rb_config_path)
+ end
+
# Public: Sets additional environment variables for vite-plugin-ruby.
def to_env
CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|
unless (value = @config[option]).nil?
env["#{ ViteRuby::ENV_PREFIX }_#{ option.upcase }"] = value.to_s
@@ -57,10 +63,10 @@
[
*(watch_additional_paths + additional_entrypoints).reject { |dir|
dir.start_with?('~/') || dir.start_with?(source_code_dir)
},
"#{ source_code_dir }/**/*",
- config_path,
+ config_path.sub(/.json$/, '.{rb,json}'),
*DEFAULT_WATCHED_PATHS,
].freeze
end
private