vite_ruby 3.0.5 → 4.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6279172f955f9ca8f6a545a9c48835978d6b3329d9a19cbfe58333d8938a49aa
4
- data.tar.gz: 866f2cb6d3525a5e0f2b96e302d21919c5d32938e03bf8e03de9cdfe9126603b
3
+ metadata.gz: 3e369fc30038cbf7475208298ccc3eebbcec6ad98100b785d6303b766afc3aad
4
+ data.tar.gz: '0811dc3a900d49b9b0b3c406b32b96e852d5a367dce1c96924b6b0a936fddc39'
5
5
  SHA512:
6
- metadata.gz: e281804897b5a583ee7f3b3e76d3ac4c36df10de19c5d14fc56bf09bd12537704acf50bd95f937e4f0fe17c10c78e1c5d131112e29ba1d5e45a0dfbb32d7f3bd
7
- data.tar.gz: a7c8e59b77ce3ce3b1de7e98198da7a367140f8844411dcb1048faeaa3dd680f32c7fda1b5d60e4c2c0c637a9a196b36ce9528ef4f0108e6683fc1b2b0bcb007
6
+ metadata.gz: ef190e8c53cf93255f56a69fa7db7fe684f1fc4924b21aca81d9d2160ec117accf643771a5692bf58225884958fa06fc3b1e713241eaa6f2f223b8fca35e216a
7
+ data.tar.gz: 22b63dc5256c147ddf084f0324f2e6a236b86b654e6cd63e99da2608c6869290aa80885b8d9c61f8c7056df449464cb24831717de5e1a0857b5cf28af303700c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ # [](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.8...vite_ruby@) (2022-01-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **experimental:** add support for Subresource Integrity via vite-plugin-manifest-sri ([0b3142c](https://github.com/ElMassimo/vite_ruby/commit/0b3142cd9d569a5f56821f53cdade337779bb0c1))
7
+
8
+
9
+
10
+ ## [3.0.8](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.7...vite_ruby@3.0.8) (2022-01-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * remove .DS_Store from installation .gitignore ([#178](https://github.com/ElMassimo/vite_ruby/issues/178)) ([5a0931d](https://github.com/ElMassimo/vite_ruby/commit/5a0931d63318ab5b1bf9ead680540c015afd471a))
16
+
17
+
18
+
19
+ ## [3.0.7](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.6...vite_ruby@3.0.7) (2021-12-27)
20
+
21
+
22
+
23
+ ## [3.0.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.5...vite_ruby@3.0.6) (2021-12-24)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * 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))
29
+
30
+
31
+ ### Features
32
+
33
+ * 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))
34
+
35
+
36
+
1
37
  ## [3.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.4...vite_ruby@3.0.5) (2021-12-17)
2
38
 
3
39
 
@@ -95,8 +95,9 @@ private
95
95
  /public/vite-dev
96
96
  /public/vite-test
97
97
  node_modules
98
+ # Vite uses dotenv and suggests to ignore local-only env files. See
99
+ # https://vitejs.dev/guide/env-and-mode.html#env-files
98
100
  *.local
99
- .DS_Store
100
101
  GITIGNORE
101
102
  end
102
103
 
@@ -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
@@ -22,16 +22,15 @@ class ViteRuby::Manifest
22
22
  lookup!(name, **options).fetch('file')
23
23
  end
24
24
 
25
- # Public: Returns scripts, imported modules, and stylesheets for the specified
25
+ # Public: Returns entries, imported modules, and stylesheets for the specified
26
26
  # entrypoint files.
27
27
  def resolve_entries(*names, **options)
28
28
  entries = names.map { |name| lookup!(name, **options) }
29
- script_paths = entries.map { |entry| entry.fetch('file') }
30
29
 
31
30
  imports = dev_server_running? ? [] : entries.flat_map { |entry| entry['imports'] }.compact.uniq
32
31
  {
33
- scripts: script_paths,
34
- imports: imports.map { |entry| entry.fetch('file') }.uniq,
32
+ main: entries.map(&TO_ENTRY),
33
+ imports: imports.map(&TO_ENTRY).uniq,
35
34
  stylesheets: dev_server_running? ? [] : (entries + imports).flat_map { |entry| entry['css'] }.compact.uniq,
36
35
  }
37
36
  end
@@ -63,6 +62,9 @@ class ViteRuby::Manifest
63
62
 
64
63
  protected
65
64
 
65
+ # Internal: Returns a [src, attrs] entry.
66
+ TO_ENTRY = ->(entry) { [entry.fetch('file'), entry.slice('integrity').symbolize_keys] }
67
+
66
68
  # Internal: Strict version of lookup.
67
69
  #
68
70
  # Returns a relative path for the asset, or raises an error if not found.
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '3.0.5'
4
+ VERSION = '4.0.0.alpha1'
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
@@ -122,7 +122,12 @@ class ViteRuby
122
122
 
123
123
  # Public: Current instance configuration for Vite.
124
124
  def config
125
- @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
126
131
  end
127
132
 
128
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.5
4
+ version: 4.0.0.alpha1
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-17 00:00:00.000000000 Z
11
+ date: 2022-01-18 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.5/vite_ruby
205
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.0.5/vite_ruby/CHANGELOG.md
204
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@4.0.0.alpha1/vite_ruby
205
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@4.0.0.alpha1/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: []
@@ -215,11 +215,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
215
  version: '2.4'
216
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  requirements:
218
- - - ">="
218
+ - - ">"
219
219
  - !ruby/object:Gem::Version
220
- version: '0'
220
+ version: 1.3.1
221
221
  requirements: []
222
- rubygems_version: 3.1.4
222
+ rubygems_version: 3.2.32
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: Use Vite in Ruby and bring joy to your JavaScript experience