Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vite_gdk.rb')
-rw-r--r--lib/vite_gdk.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/vite_gdk.rb b/lib/vite_gdk.rb
new file mode 100644
index 00000000000..f50c6cab515
--- /dev/null
+++ b/lib/vite_gdk.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module ViteGdk
+ def self.load_gdk_vite_config
+ # can't use Rails.env.production? here because this file is required outside of Gitlab app instance
+ return if ENV['RAILS_ENV'] == 'production'
+
+ return unless File.exist?(vite_gdk_config_path)
+
+ config = YAML.safe_load_file(vite_gdk_config_path)
+ enabled = config.fetch('enabled', false)
+ # ViteRuby doesn't like if env vars aren't strings
+ ViteRuby.env['VITE_ENABLED'] = enabled.to_s
+
+ return unless enabled
+
+ ViteRuby.configure(
+ host: config.fetch('host', 'localhost'),
+ port: Integer(config.fetch('port', 3038))
+ )
+ end
+
+ def self.vite_gdk_config_path
+ File.join(__dir__, '../config/vite.gdk.json')
+ end
+end