lib/vite_ruby/config.rb in vite_ruby-3.0.0.beta.1 vs lib/vite_ruby/config.rb in vite_ruby-3.0.0.beta.2

- old
+ new

@@ -50,29 +50,42 @@ env["#{ ViteRuby::ENV_PREFIX }_#{ option.upcase }"] = value.to_s end end.merge(ViteRuby.env) end + # Internal: Files and directories that should be watched for changes. + def watched_paths + [ + *(watch_additional_paths + additional_entrypoints).reject { |dir| + dir.start_with?('~/') || dir.start_with?(source_code_dir) + }, + "#{ source_code_dir }/**/*", + config_path, + *DEFAULT_WATCHED_PATHS, + ].freeze + end + private # Internal: Coerces all the configuration values, in case they were passed # as environment variables which are always strings. def coerce_values(config) config['mode'] = config['mode'].to_s config['port'] = config['port'].to_i config['root'] = Pathname.new(config['root']) config['build_cache_dir'] = config['root'].join(config['build_cache_dir']) - coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https') + coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https', 'skip_compatibility_check') end # Internal: Coerces configuration options to boolean. def coerce_booleans(config, *names) names.each { |name| config[name] = [true, 'true'].include?(config[name]) } end def initialize(attrs) @config = attrs.tap { |config| coerce_values(config) }.freeze + ViteRuby::CompatibilityCheck.verify_plugin_version(root) unless skip_compatibility_check end class << self private :new @@ -141,13 +154,26 @@ # Internal: Shared configuration with the Vite plugin for Ruby. DEFAULT_CONFIG = load_json("#{ __dir__ }/../../default.vite.json").freeze # Internal: Configuration options that can not be provided as env vars. - NOT_CONFIGURABLE_WITH_ENV = %w[additional_input_globs watch_additional_paths].freeze + NOT_CONFIGURABLE_WITH_ENV = %w[additional_entrypoints watch_additional_paths].freeze # Internal: Configuration options that can be provided as env vars. - CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root] - NOT_CONFIGURABLE_WITH_ENV).freeze + CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root skip_compatibility_check] - NOT_CONFIGURABLE_WITH_ENV).freeze + + # Internal: If any of these files is modified the build won't be skipped. + DEFAULT_WATCHED_PATHS = %w[ + package-lock.json + package.json + pnpm-lock.yaml + postcss.config.js + tailwind.config.js + vite.config.js + vite.config.ts + windi.config.ts + yarn.lock + ].freeze public # Define getters for the configuration options. (CONFIGURABLE_WITH_ENV + NOT_CONFIGURABLE_WITH_ENV).each do |option|