vite_ruby 3.0.3 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23aa04b92951f5416f6c6efdab61f834a69893c5890196181ed3533e3495a1dc
4
- data.tar.gz: bc3926785ea462a5f3ac9bb3fa216d2c74eb7997b30ee8be6aeb5191de43a4c4
3
+ metadata.gz: 2fa78fa55a3f2e8d6607fa60c7070562fe0d4781457d186426c1de8618d5d38f
4
+ data.tar.gz: 354e7680dc0b7dd4931052d656bb20daa302d6f3763c3f2a02e11ff9cea533df
5
5
  SHA512:
6
- metadata.gz: afa2927630c8005cd0510cac26355379870ef0b5c6df0058e4ea337cdd0b0b077c2d847dafb73832fc2290a567fe82dbb955adbf4aa3e5865bc3db80e561a337
7
- data.tar.gz: 118cadf8125ef8759fa7251fe8cef36429c498b3ec802d0862e66a716576e7ec5caf7c46e99e49d58f7ed78479ddd740d58df6f3bb0b5028ffe9028c3042ad79
6
+ metadata.gz: 1da507b4e87c31d1a12fca3d2306db2bfc37067246104ea664a4220d650aee95b571e152a9ec08f9ecad84c5d721690a7faeb7e03c144246c13646c42754a13d
7
+ data.tar.gz: 688961190326cac3ea2da957534efa6b8425aade5b3d3ba9948ae685ed86324298acca0aea6293cc015b48765dda0f093a7d868d1478708a346be7a6b384ea04
data/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
1
+ ## [3.0.7](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.6...vite_ruby@3.0.7) (2021-12-27)
2
+
3
+
4
+
5
+ ## [3.0.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.5...vite_ruby@3.0.6) (2021-12-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * allow providing an empty public output dir (close [#161](https://github.com/ElMassimo/vite_ruby/issues/161)) ([#164](https://github.com/ElMassimo/vite_ruby/issues/164)) ([ef48c9b](https://github.com/ElMassimo/vite_ruby/commit/ef48c9b39084a96364a783fa670bd6ec68dfa289))
11
+
12
+
13
+ ### Features
14
+
15
+ * support ruby config file for advanced configuration (close [#162](https://github.com/ElMassimo/vite_ruby/issues/162)) ([34e63fd](https://github.com/ElMassimo/vite_ruby/commit/34e63fdd546078dfc94f2c546b096aa296a47d37))
16
+
17
+
18
+
19
+ ## [3.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.4...vite_ruby@3.0.5) (2021-12-17)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * ensure vite_plugin_legacy is upgraded by the upgrade command ([2f9437d](https://github.com/ElMassimo/vite_ruby/commit/2f9437d248e27aa03b5b8a1df3e3d6a52c791cd1))
25
+
26
+
27
+
28
+ ## [3.0.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.3...vite_ruby@3.0.4) (2021-12-17)
29
+
30
+ ### BREAKING CHANGES
31
+
32
+ * if using `vite_plugin_legacy`, make sure to upgrade to 3.0.1
33
+
34
+ ### Bug Fixes
35
+
36
+ * handle new virtual legacy-polyfill name ([#157](https://github.com/ElMassimo/vite_ruby/issues/157)) ([a34e77f](https://github.com/ElMassimo/vite_ruby/commit/a34e77f3b342c9171adc50adfd5220b57bddb961))
37
+
38
+
1
39
  ## [3.0.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.2...vite_ruby@3.0.3) (2021-12-09)
2
40
 
3
41
 
@@ -43,6 +43,12 @@ class ViteRuby::Config
43
43
  root.join(source_code_dir)
44
44
  end
45
45
 
46
+ # Public: Loads an optional config/vite.rb file that can modify ViteRuby.env
47
+ def load_ruby_config
48
+ rb_config_path = File.expand_path(config_path.sub(/.json$/, '.rb'), root)
49
+ load rb_config_path if File.exist?(rb_config_path)
50
+ end
51
+
46
52
  # Public: Sets additional environment variables for vite-plugin-ruby.
47
53
  def to_env
48
54
  CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|
@@ -59,7 +65,7 @@ class ViteRuby::Config
59
65
  dir.start_with?('~/') || dir.start_with?(source_code_dir)
60
66
  },
61
67
  "#{ source_code_dir }/**/*",
62
- config_path,
68
+ config_path.sub(/.json$/, '.{rb,json}'),
63
69
  *DEFAULT_WATCHED_PATHS,
64
70
  ].freeze
65
71
  end
@@ -31,10 +31,14 @@ private
31
31
 
32
32
  def rewrite_uri_for_vite(env)
33
33
  uri = env.fetch('REQUEST_URI') { [env['PATH_INFO'], env['QUERY_STRING']].reject { |str| str.to_s.strip.empty? }.join('?') }
34
+ env['PATH_INFO'], env['QUERY_STRING'] = (env['REQUEST_URI'] = normalize_uri(uri)).split('?')
35
+ end
36
+
37
+ def normalize_uri(uri)
38
+ uri
34
39
  .sub(HOST_WITH_PORT_REGEX, '/') # Hanami adds the host and port.
35
40
  .sub('.ts.js', '.ts') # Hanami's javascript helper always adds the extension.
36
41
  .sub(/(\.(?!min|module)\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
37
- env['PATH_INFO'], env['QUERY_STRING'] = (env['REQUEST_URI'] = uri).split('?')
38
42
  end
39
43
 
40
44
  def forward_to_vite_dev_server(env)
@@ -49,7 +53,7 @@ private
49
53
  end
50
54
 
51
55
  def vite_should_handle?(env)
52
- path = env['PATH_INFO']
56
+ path = normalize_uri(env['PATH_INFO'])
53
57
  return true if path.start_with?(vite_asset_url_prefix) # Vite asset
54
58
  return true if path.start_with?(VITE_DEPENDENCY_PREFIX) # Packages and imports
55
59
  return true if file_in_vite_root?(path) # Fallback if Vite can serve the file
@@ -61,6 +65,6 @@ private
61
65
  end
62
66
 
63
67
  def vite_asset_url_prefix
64
- @vite_asset_url_prefix ||= "/#{ config.public_output_dir }/"
68
+ @vite_asset_url_prefix ||= config.public_output_dir.empty? ? "\0" : "/#{ config.public_output_dir }/"
65
69
  end
66
70
  end
@@ -147,9 +147,10 @@ private
147
147
 
148
148
  # Internal: Resolves the manifest entry name for the specified resource.
149
149
  def resolve_entry_name(name, type: nil)
150
- name = with_file_extension(name.to_s, type)
150
+ return resolve_virtual_entry(name) if type == :virtual
151
151
 
152
- raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.') && !name.include?('legacy-polyfills')
152
+ name = with_file_extension(name.to_s, type)
153
+ raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.')
153
154
 
154
155
  # Explicit path, relative to the source_code_dir.
155
156
  name.sub(%r{^~/(.+)$}) { return Regexp.last_match(1) }
@@ -171,6 +172,11 @@ private
171
172
  end
172
173
  end
173
174
 
175
+ # Internal: Resolves a virtual entry by walking all the manifest keys.
176
+ def resolve_virtual_entry(name)
177
+ manifest.keys.find { |file| file.include?(name) } || name
178
+ end
179
+
174
180
  # Internal: Adds a file extension to the file name, unless it already has one.
175
181
  def with_file_extension(name, entry_type)
176
182
  if File.extname(name).empty? && (ext = extension_for_type(entry_type))
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '3.0.3'
4
+ VERSION = '3.0.7'
5
5
 
6
6
  # Internal: Versions used by default when running `vite install`.
7
- DEFAULT_VITE_VERSION = '^2.6.13'
8
- DEFAULT_PLUGIN_VERSION = '^3.0.2'
7
+ DEFAULT_VITE_VERSION = '^2.7.7'
8
+ DEFAULT_PLUGIN_VERSION = '^3.0.5'
9
9
  end
data/lib/vite_ruby.rb CHANGED
@@ -27,6 +27,7 @@ class ViteRuby
27
27
  'vite_padrino' => 'padrino',
28
28
  'jekyll-vite' => 'jekyll',
29
29
  'vite_rails_legacy' => 'rails',
30
+ 'vite_plugin_legacy' => 'rack',
30
31
  }
31
32
 
32
33
  class << self
@@ -121,7 +122,12 @@ class ViteRuby
121
122
 
122
123
  # Public: Current instance configuration for Vite.
123
124
  def config
124
- @config ||= ViteRuby::Config.resolve_config(**@config_options)
125
+ unless defined?(@config)
126
+ @config = ViteRuby::Config.resolve_config(**@config_options)
127
+ @config.load_ruby_config
128
+ end
129
+
130
+ @config
125
131
  end
126
132
 
127
133
  # Public: Enables looking up assets managed by Vite using name and type.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -201,8 +201,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
201
201
  licenses:
202
202
  - MIT
203
203
  metadata:
204
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.0.3/vite_ruby
205
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.0.3/vite_ruby/CHANGELOG.md
204
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.0.7/vite_ruby
205
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.0.7/vite_ruby/CHANGELOG.md
206
206
  post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
207
207
  manually, please run:\n\tbundle exec vite upgrade"
208
208
  rdoc_options: []