vite_rails 1.0.7 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/CONTRIBUTING.md +0 -1
  4. data/README.md +34 -8
  5. data/lib/install/config/vite.config.ts +0 -3
  6. data/lib/install/javascript/entrypoints/application.js +8 -4
  7. data/lib/install/template.rb +3 -3
  8. data/lib/tasks/vite/build.rake +12 -6
  9. data/lib/tasks/vite/clean.rake +1 -3
  10. data/lib/tasks/vite/install_dependencies.rake +3 -9
  11. data/lib/tasks/vite/verify_install.rake +3 -3
  12. data/lib/vite_rails.rb +23 -34
  13. data/lib/vite_rails/builder.rb +11 -13
  14. data/lib/vite_rails/commands.rb +51 -10
  15. data/lib/vite_rails/config.rb +70 -35
  16. data/lib/vite_rails/dev_server_proxy.rb +26 -18
  17. data/lib/vite_rails/helper.rb +14 -10
  18. data/lib/vite_rails/manifest.rb +27 -22
  19. data/lib/vite_rails/runner.rb +3 -6
  20. data/lib/vite_rails/version.rb +1 -1
  21. data/package.json +9 -2
  22. data/package/default.vite.json +2 -1
  23. data/test/builder_test.rb +27 -22
  24. data/test/commands_test.rb +67 -0
  25. data/test/config_test.rb +133 -0
  26. data/test/dev_server_proxy_test.rb +102 -0
  27. data/test/dev_server_test.rb +0 -30
  28. data/test/engine_rake_tasks_test.rb +56 -17
  29. data/test/helper_test.rb +40 -103
  30. data/test/manifest_test.rb +39 -29
  31. data/test/mode_test.rb +6 -11
  32. data/test/mounted_app/test/dummy/config/vite.json +5 -11
  33. data/test/mounted_app/test/dummy/package.json +5 -4
  34. data/test/mounted_app/test/dummy/yarn.lock +208 -0
  35. data/test/rake_tasks_test.rb +7 -21
  36. data/test/runner_test.rb +31 -0
  37. data/test/test_app/app/frontend/entrypoints/application.js +2 -0
  38. data/test/test_app/config/vite.json +0 -2
  39. data/test/test_app/config/vite_additional_paths.json +5 -0
  40. data/test/test_app/config/vite_public_dir.json +5 -0
  41. data/test/test_app/public/vite-production/manifest-assets.json +10 -0
  42. data/test/test_app/public/vite-production/manifest.json +39 -0
  43. data/test/test_helper.rb +48 -14
  44. metadata +25 -25
  45. data/test/command_test.rb +0 -35
  46. data/test/configuration_test.rb +0 -80
  47. data/test/dev_server_runner_test.rb +0 -83
  48. data/test/test_app/app/javascript/entrypoints/application.js +0 -10
  49. data/test/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
  50. data/test/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
  51. data/test/test_app/config/vite_public_root.yml +0 -20
  52. data/test/test_app/public/vite/manifest.json +0 -36
  53. data/test/vite_runner_test.rb +0 -59
  54. data/test/webpacker_test.rb +0 -15
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  # Public: Allows to resolve configuration sourced from `config/vite.json` and
4
6
  # environment variables, combining them with the default options.
5
7
  class ViteRails::Config
6
8
  delegate :as_json, :inspect, to: :@config
7
9
 
8
- def initialize(config)
9
- @config = config.tap { coerce_values(config) }.freeze
10
-
11
- config.each_key do |option|
12
- define_singleton_method(option) { @config[option] }
13
- end
10
+ def initialize(attrs)
11
+ @config = attrs.tap { |config| coerce_values(config) }.freeze
14
12
  end
15
13
 
16
14
  def protocol
@@ -26,9 +24,33 @@ class ViteRails::Config
26
24
  build_output_dir.join('manifest.json')
27
25
  end
28
26
 
27
+ # Internal: Path where vite-plugin-ruby outputs the assets manifest file.
28
+ def assets_manifest_path
29
+ build_output_dir.join('manifest-assets.json')
30
+ end
31
+
29
32
  # Public: The directory where Vite will store the built assets.
30
33
  def build_output_dir
31
- public_dir.join(public_output_dir)
34
+ root.join(public_dir, public_output_dir)
35
+ end
36
+
37
+ # Public: The directory where the entries are located.
38
+ def resolved_entrypoints_dir
39
+ root.join(source_code_dir, entrypoints_dir)
40
+ end
41
+
42
+ # Internal: The directory where Vite stores its processing cache.
43
+ def vite_cache_dir
44
+ root.join('node_modules/.vite')
45
+ end
46
+
47
+ # Public: Sets additional environment variables for vite-plugin-ruby.
48
+ def to_env
49
+ CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|
50
+ unless (value = @config[option]).nil?
51
+ env["#{ ViteRails::ENV_PREFIX }_#{ option.upcase }"] = value.to_s
52
+ end
53
+ end.merge(ViteRails.env)
32
54
  end
33
55
 
34
56
  private
@@ -36,10 +58,11 @@ private
36
58
  # Internal: Coerces all the configuration values, in case they were passed
37
59
  # as environment variables which are always strings.
38
60
  def coerce_values(config)
39
- coerce_booleans(config, 'auto_build', 'https')
40
- coerce_paths(config, 'assets_dir', 'build_cache_dir', 'config_path', 'public_dir', 'source_code_dir', 'public_output_dir', 'root')
61
+ config['mode'] = config['mode'].to_s
41
62
  config['port'] = config['port'].to_i
42
- config['root'] ||= Rails.root
63
+ config['root'] = Pathname.new(config['root'])
64
+ config['build_cache_dir'] = config['root'].join(config['build_cache_dir'])
65
+ coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https')
43
66
  end
44
67
 
45
68
  # Internal: Coerces configuration options to boolean.
@@ -47,58 +70,70 @@ private
47
70
  names.each { |name| config[name] = [true, 'true'].include?(config[name]) }
48
71
  end
49
72
 
50
- # Internal: Converts configuration options to pathname.
51
- def coerce_paths(config, *names)
52
- names.each { |name| config[name] = Pathname.new(config[name]) unless config[name].nil? }
53
- end
54
-
55
73
  class << self
56
74
  # Public: Returns the project configuration for Vite.
57
- def resolve_config
58
- new DEFAULT_CONFIG.merge(config_from_file).merge(config_from_env)
59
- rescue Errno::ENOENT => error
60
- warn "Check that your vite.json configuration file is available in the load path. #{ error.message }"
61
- new DEFAULT_CONFIG.merge(config_from_env)
75
+ def resolve_config(**attrs)
76
+ config = attrs.transform_keys(&:to_s).reverse_merge(config_defaults)
77
+ file_path = File.join(config['root'], config['config_path'])
78
+ file_config = config_from_file(file_path, mode: config['mode'])
79
+ new DEFAULT_CONFIG.merge(file_config).merge(config_from_env).merge(config)
62
80
  end
63
81
 
64
82
  private
65
83
 
84
+ # Internal: Default values for a Rails application.
85
+ def config_defaults
86
+ {
87
+ 'asset_host' => option_from_env('asset_host') || Rails.application&.config&.action_controller&.asset_host,
88
+ 'config_path' => option_from_env('config_path') || DEFAULT_CONFIG.fetch('config_path'),
89
+ 'mode' => option_from_env('mode') || Rails.env.to_s,
90
+ 'root' => option_from_env('root') || Rails.root || Dir.pwd,
91
+ }
92
+ end
93
+
66
94
  # Internal: Used to load a JSON file from the specified path.
67
95
  def load_json(path)
68
96
  JSON.parse(File.read(File.expand_path(path))).deep_transform_keys(&:underscore)
69
97
  end
70
98
 
71
99
  # Internal: Retrieves a configuration option from environment variables.
72
- def config_option_from_env(name)
73
- ENV["#{ ViteRails::ENV_PREFIX }_#{ name.upcase }"]
100
+ def option_from_env(name)
101
+ ViteRails.env["#{ ViteRails::ENV_PREFIX }_#{ name.upcase }"]
74
102
  end
75
103
 
76
104
  # Internal: Extracts the configuration options provided as env vars.
77
105
  def config_from_env
78
- CONFIGURABLE_WITH_ENV.each_with_object({}) do |key, env_vars|
79
- if value = config_option_from_env(key)
80
- env_vars[key] = value
106
+ CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env_vars|
107
+ if value = option_from_env(option)
108
+ env_vars[option] = value
81
109
  end
82
- end.merge(mode: vite_mode)
83
- end
84
-
85
- # Internal: The mode Vite should run on.
86
- def vite_mode
87
- config_option_from_env('mode') || Rails.env.to_s
110
+ end
88
111
  end
89
112
 
90
113
  # Internal: Loads the configuration options provided in a JSON file.
91
- def config_from_file
92
- path = config_option_from_env('config_path') || DEFAULT_CONFIG.fetch('config_path')
114
+ def config_from_file(path, mode:)
93
115
  multi_env_config = load_json(path)
94
116
  multi_env_config.fetch('all', {})
95
- .merge(multi_env_config.fetch(vite_mode, {}))
117
+ .merge(multi_env_config.fetch(mode, {}))
118
+ rescue Errno::ENOENT => error
119
+ warn "Check that your vite.json configuration file is available in the load path. #{ error.message }"
120
+ {}
96
121
  end
97
122
  end
98
123
 
99
124
  # Internal: Shared configuration with the Vite plugin for Ruby.
100
125
  DEFAULT_CONFIG = load_json("#{ __dir__ }/../../package/default.vite.json").freeze
101
126
 
127
+ # Internal: Configuration options that can not be provided as env vars.
128
+ NOT_CONFIGURABLE_WITH_ENV = %w[watch_additional_paths].freeze
129
+
102
130
  # Internal: Configuration options that can be provided as env vars.
103
- CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + ['root']).freeze
131
+ CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root] - NOT_CONFIGURABLE_WITH_ENV).freeze
132
+
133
+ public
134
+
135
+ # Define getters for the configuration options.
136
+ (CONFIGURABLE_WITH_ENV + NOT_CONFIGURABLE_WITH_ENV).each do |option|
137
+ define_method(option) { @config[option] }
138
+ end
104
139
  end
@@ -14,18 +14,8 @@ class ViteRails::DevServerProxy < Rack::Proxy
14
14
 
15
15
  # Rack: Intercept asset requests and send them to the Vite server.
16
16
  def perform_request(env)
17
- if vite_should_handle?(env['REQUEST_URI'], env['HTTP_REFERER']) && dev_server.running?
18
- env['REQUEST_URI'] = env['REQUEST_URI']
19
- .sub(vite_asset_url_prefix, '/')
20
- .sub('.ts.js', '.ts') # Patch: Rails helpers always append the extension.
21
- env['PATH_INFO'], env['QUERY_STRING'] = env['REQUEST_URI'].split('?')
22
-
23
- env['HTTP_HOST'] = env['HTTP_X_FORWARDED_HOST'] = config.host
24
- env['HTTP_X_FORWARDED_SERVER'] = config.host_with_port
25
- env['HTTP_PORT'] = env['HTTP_X_FORWARDED_PORT'] = config.port.to_s
26
- env['HTTP_X_FORWARDED_PROTO'] = env['HTTP_X_FORWARDED_SCHEME'] = config.protocol
27
- env['HTTPS'] = env['HTTP_X_FORWARDED_SSL'] = 'off' unless config.https
28
- env['SCRIPT_NAME'] = ''
17
+ if vite_should_handle?(env) && dev_server_running?
18
+ forward_to_vite_dev_server(env)
29
19
  super(env)
30
20
  else
31
21
  @app.call(env)
@@ -34,13 +24,31 @@ class ViteRails::DevServerProxy < Rack::Proxy
34
24
 
35
25
  private
36
26
 
37
- delegate :config, :dev_server, to: :@vite_rails
27
+ delegate :config, :dev_server_running?, to: :@vite_rails
38
28
 
39
- def vite_should_handle?(url, referer)
40
- return true if url.start_with?(vite_asset_url_prefix) # Vite Asset
41
- return true if url.start_with?(VITE_DEPENDENCY_PREFIX) # Vite Package Asset
42
- return true if url.include?('?t=') # Hot Reload
43
- return true if referer && URI.parse(referer).path.start_with?(vite_asset_url_prefix) # Entry Imported from another Entry.
29
+ def rewrite_uri_for_vite(env)
30
+ uri = env.fetch('REQUEST_URI') { [env['PATH_INFO'], env['QUERY_STRING']].reject(&:blank?).join('?') }
31
+ .sub(vite_asset_url_prefix, '/')
32
+ env['PATH_INFO'], env['QUERY_STRING'] = (env['REQUEST_URI'] = uri).split('?')
33
+ end
34
+
35
+ def forward_to_vite_dev_server(env)
36
+ rewrite_uri_for_vite(env)
37
+ env['HTTP_HOST'] = env['HTTP_X_FORWARDED_HOST'] = config.host
38
+ env['HTTP_X_FORWARDED_SERVER'] = config.host_with_port
39
+ env['HTTP_PORT'] = env['HTTP_X_FORWARDED_PORT'] = config.port.to_s
40
+ env['HTTP_X_FORWARDED_PROTO'] = env['HTTP_X_FORWARDED_SCHEME'] = config.protocol
41
+ env['HTTPS'] = env['HTTP_X_FORWARDED_SSL'] = 'off' unless config.https
42
+ env['SCRIPT_NAME'] = ''
43
+ end
44
+
45
+ def vite_should_handle?(env)
46
+ path, query, referer = env['PATH_INFO'], env['QUERY_STRING'], env['HTTP_REFERER']
47
+ return true if path.start_with?(vite_asset_url_prefix) # Vite asset
48
+ return true if path.start_with?(VITE_DEPENDENCY_PREFIX) # Packages and imports
49
+ return true if query&.start_with?('t=') # Hot Reload for a stylesheet
50
+ return true if query&.start_with?('import&') # Hot Reload for an imported entrypoint
51
+ return true if referer && URI.parse(referer).path.start_with?(vite_asset_url_prefix) # Entry imported from another entry.
44
52
  end
45
53
 
46
54
  def vite_asset_url_prefix
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Public: Allows to render HTML tags for scripts and styles processed by Vite.
4
4
  module ViteRails::Helper
5
- DEFAULT_VITE_SKIP_PRELOAD_TAGS = Rails::VERSION::MAJOR <= 5 && Rails::VERSION::MINOR < 2
5
+ DEFAULT_VITE_SKIP_PRELOAD_TAGS = Rails.gem_version < Gem::Version.new('5.2.0')
6
6
 
7
7
  # Public: Returns the current Vite Rails instance.
8
8
  def current_vite_instance
@@ -11,15 +11,17 @@ module ViteRails::Helper
11
11
 
12
12
  # Public: Renders a script tag for vite/client to enable HMR in development.
13
13
  def vite_client_tag
14
- content_tag('script', '', src: '/@vite/client', type: 'module') if ViteRails.dev_server_running?
14
+ return unless current_vite_instance.dev_server_running?
15
+
16
+ content_tag('script', '', src: current_vite_instance.manifest.prefix_vite_asset('@vite/client'), type: 'module')
15
17
  end
16
18
 
17
- # Public: Computes the relative path for the specified given Vite asset.
19
+ # Public: Resolves the path for the specified Vite asset.
18
20
  #
19
21
  # Example:
20
22
  # <%= vite_asset_path 'calendar.css' %> # => "/vite/assets/calendar-1016838bab065ae1e122.css"
21
23
  def vite_asset_path(name, **options)
22
- current_vite_instance.manifest.lookup!(name, **options).fetch('file')
24
+ path_to_asset current_vite_instance.manifest.lookup!(name, **options).fetch('file')
23
25
  end
24
26
 
25
27
  # Public: Renders a <script> tag for the specified Vite entrypoints.
@@ -31,15 +33,17 @@ module ViteRails::Helper
31
33
  crossorigin: 'anonymous',
32
34
  **options)
33
35
  js_entries = names.map { |name| current_vite_instance.manifest.lookup!(name, type: asset_type) }
34
- js_tags = javascript_include_tag(*js_entries.map { |entry| entry['file'] }, type: type, crossorigin: crossorigin, **options)
36
+ js_tags = javascript_include_tag(*js_entries.map { |entry| entry['file'] }, crossorigin: crossorigin, type: type, **options)
37
+
38
+ preload_entries = js_entries.flat_map { |entry| entry['imports'] }.compact.uniq
35
39
 
36
- unless skip_preload_tags || ViteRails.dev_server_running?
37
- preload_paths = js_entries.flat_map { |entry| entry['imports'] }.compact.uniq
40
+ unless skip_preload_tags || current_vite_instance.dev_server_running?
41
+ preload_paths = preload_entries.map { |entry| entry['file'] }.compact.uniq
38
42
  preload_tags = preload_paths.map { |path| preload_link_tag(path, crossorigin: crossorigin) }
39
43
  end
40
44
 
41
- unless skip_style_tags || ViteRails.dev_server_running?
42
- style_paths = names.map { |name| current_vite_instance.manifest.lookup(name, type: :stylesheet)&.fetch('file') }.compact
45
+ unless skip_style_tags || current_vite_instance.dev_server_running?
46
+ style_paths = (js_entries + preload_entries).flat_map { |entry| entry['css'] }.compact.uniq
43
47
  style_tags = stylesheet_link_tag(*style_paths)
44
48
  end
45
49
 
@@ -51,7 +55,7 @@ module ViteRails::Helper
51
55
  # NOTE: Because TypeScript is not a valid target in browsers, we only specify
52
56
  # the ts file when running the Vite development server.
53
57
  def vite_typescript_tag(*names, **options)
54
- vite_javascript_tag(*names, asset_type: :typescript, **options)
58
+ vite_javascript_tag(*names, asset_type: :typescript, extname: false, **options)
55
59
  end
56
60
 
57
61
  # Public: Renders a <link> tag for the specified Vite entrypoints.
@@ -31,17 +31,22 @@ class ViteRails::Manifest
31
31
  # Example:
32
32
  # ViteRails.manifest.lookup('calendar.js')
33
33
  # # { "file" => "/vite/assets/calendar-1016838bab065ae1e122.js", "imports" => [] }
34
- def lookup(name, type:)
34
+ def lookup(name, type: nil)
35
35
  build if should_build?
36
36
 
37
37
  find_manifest_entry(with_file_extension(name, type))
38
38
  end
39
39
 
40
- # Public: Refreshes the cached mappings by reading the updated manifest.
40
+ # Public: Refreshes the cached mappings by reading the updated manifest files.
41
41
  def refresh
42
42
  @manifest = load_manifest
43
43
  end
44
44
 
45
+ # Public: Scopes an asset to the output folder in public, as a path.
46
+ def prefix_vite_asset(path)
47
+ File.join("/#{ config.public_output_dir }", path)
48
+ end
49
+
45
50
  private
46
51
 
47
52
  delegate :config, :builder, :dev_server_running?, to: :@vite_rails
@@ -55,7 +60,7 @@ private
55
60
  # Internal: Finds the specified entry in the manifest.
56
61
  def find_manifest_entry(name)
57
62
  if dev_server_running?
58
- { 'file' => "/#{ config.public_output_dir.join(name.to_s) }" }
63
+ { 'file' => prefix_vite_asset(name.to_s) }
59
64
  else
60
65
  manifest[name.to_s]
61
66
  end
@@ -76,15 +81,18 @@ private
76
81
  @manifest ||= load_manifest
77
82
  end
78
83
 
79
- # Internal: Returns a Hash with the entries in the manifest.json.
84
+ # Internal: Loads and merges the manifest files, resolving the asset paths.
80
85
  def load_manifest
81
- if config.manifest_path.exist?
82
- JSON.parse(config.manifest_path.read).each do |_, entry|
83
- entry['file'] = within_public_output_dir(entry['file'])
84
- entry['imports'] = entry['imports']&.map { |path| within_public_output_dir(path) }
85
- end
86
- else
87
- {}
86
+ files = [config.manifest_path, config.assets_manifest_path].select(&:exist?)
87
+ files.map { |path| JSON.parse(path.read) }.inject({}, &:merge).tap(&method(:resolve_references))
88
+ end
89
+
90
+ # Internal: Resolves the paths that reference a manifest entry.
91
+ def resolve_references(manifest)
92
+ manifest.each_value do |entry|
93
+ entry['file'] = prefix_vite_asset(entry['file'])
94
+ entry['css'] = Array.wrap(entry['css']).map { |path| prefix_vite_asset(path) } if entry['css']
95
+ entry['imports']&.map! { |name| manifest.fetch(name) }
88
96
  end
89
97
  end
90
98
 
@@ -92,12 +100,8 @@ private
92
100
  def with_file_extension(name, entry_type)
93
101
  return name unless File.extname(name.to_s).empty?
94
102
 
95
- "#{ name }.#{ extension_for_type(entry_type) }"
96
- end
97
-
98
- # Internal: Scopes the paths in the manifest to the output folder in public.
99
- def within_public_output_dir(path)
100
- "/#{ config.public_output_dir.join(path) }"
103
+ extension = extension_for_type(entry_type)
104
+ extension ? "#{ name }.#{ extension }" : name
101
105
  end
102
106
 
103
107
  # Internal: Allows to receive :javascript and :stylesheet as :type in helpers.
@@ -105,8 +109,8 @@ private
105
109
  case entry_type
106
110
  when :javascript then 'js'
107
111
  when :stylesheet then 'css'
108
- when :typescript then dev_server_running? ? 'ts' : 'js'
109
- else entry_type.to_s
112
+ when :typescript then 'ts'
113
+ else entry_type
110
114
  end
111
115
  end
112
116
 
@@ -114,12 +118,12 @@ private
114
118
  def missing_entry_error(name, type: nil, **_options)
115
119
  file_name = with_file_extension(name, type)
116
120
  raise ViteRails::Manifest::MissingEntryError, <<~MSG
117
- Vite Rails can't find #{ file_name } in #{ config.manifest_path }.
121
+ Vite Rails can't find #{ file_name } in #{ config.manifest_path } or #{ config.assets_manifest_path }.
118
122
 
119
123
  Possible causes:
120
124
  #{ missing_entry_causes.map { |cause| "\t- #{ cause }" }.join("\n") }
121
125
 
122
- Your manifest contains:
126
+ Content in your manifests:
123
127
  #{ JSON.pretty_generate(@manifest) }
124
128
  MSG
125
129
  end
@@ -129,9 +133,10 @@ private
129
133
  [
130
134
  (dev_server_running? && 'Vite has not yet re-built your latest changes.'),
131
135
  (local && !dev_server_running? && "\"autoBuild\": false in your #{ config.mode } configuration."),
136
+ (local && !dev_server_running? && 'The Vite development server has crashed or is no longer available.'),
132
137
  'You have misconfigured config/vite.json file.',
133
138
  (!local && 'Assets have not been precompiled'),
134
- ].select(&:itself)
139
+ ].select(&:present?)
135
140
  rescue StandardError
136
141
  []
137
142
  end
@@ -31,10 +31,9 @@ private
31
31
  cmd = vite_executable
32
32
  cmd.prepend('node', '--inspect-brk') if args.include?('--debug')
33
33
  cmd.prepend('node', '--trace-deprecation') if args.delete('--trace-deprecation')
34
- args.append('--mode', ENV['RAILS_ENV']) unless args.include?('--mode') || args.include?('-m')
34
+ args.append('--mode', ViteRails.mode) unless args.include?('--mode') || args.include?('-m')
35
35
  cmd += args
36
- puts cmd.join(' ')
37
- Dir.chdir(File.expand_path('.', Dir.pwd)) { Kernel.exec(ViteRails.env, *cmd) }
36
+ Dir.chdir(File.expand_path('.', Dir.pwd)) { Kernel.exec(ViteRails.config.to_env, *cmd) }
38
37
  end
39
38
 
40
39
  # Internal: Resolves to an executable for Vite.
@@ -49,8 +48,6 @@ private
49
48
 
50
49
  # Internal: Returns a path where a Vite executable should be found.
51
50
  def vite_bin_path
52
- ENV["#{ ViteRails::ENV_PREFIX }_VITE_BIN_PATH"] || `yarn bin vite`.chomp
53
- rescue StandardError
54
- "#{ `npm bin`.chomp }/vite"
51
+ ENV["#{ ViteRails::ENV_PREFIX }_VITE_BIN_PATH"] || `yarn bin vite`.chomp.presence || "#{ `npm bin`.chomp }/vite"
55
52
  end
56
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRails
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.12'
5
5
  end
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "only-for-workflows",
3
3
  "version": "unknown",
4
+ "license": "MIT",
4
5
  "scripts": {
6
+ "docs": "npm -C docs run docs",
7
+ "docs:build": "npm -C docs run docs:build",
8
+ "docs:search": "npm -C docs run docs:search",
9
+ "docs:lint": "npm -C docs run lint",
10
+ "build": "rm -rf package/dist && npm -C package run prerelease",
11
+ "release": "rm -rf package/dist && npm -C package run release",
5
12
  "lint": "npm -C package run lint",
6
13
  "test": "npm -C package run test"
7
14
  },
8
15
  "dependencies": {
9
- "vite": "^2.0.0-beta.34",
10
- "vite-plugin-ruby": "^1.0.1"
16
+ "vite": "^2.0.0-beta.56",
17
+ "vite-plugin-ruby": "^1.0.6"
11
18
  }
12
19
  }