vite_rails 3.0.19 → 3.0.20

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: bec6203fd13439bda514b7bc060fa686a092d5abe246c0c7e3bc9bb94d57f3be
4
- data.tar.gz: 5528b478eeaf0f21630f0c546bd624879520d36ac50dd03414da68da06125998
3
+ metadata.gz: c3c69cfbf18379399d201573533ffce912b113999e8f9ac7aecae0f65de91408
4
+ data.tar.gz: 6bf2c273452988e5c918894647207a00003f09881b24aef59ad1ad3d651656ee
5
5
  SHA512:
6
- metadata.gz: ba27baf7621e86dc14fafd03b965e8f24c7aade5763ce68e94a044e93c047716cf674e2c738047e4ed17d961898e16571c80a568435a24b8c299509592d1630c
7
- data.tar.gz: d9918d6bc2f636882ac336ea29bcc66e603f654ddcc1002bb53b59026c6b066684b01b19c14ac5e957fc861162851119e05c5ff62d1e0ec093b84e907bc0c9f1
6
+ metadata.gz: e427411358568362629b98d5cfa256929a77c783ead61671d571ff41bdc620de41637d4322f4bc5a469f2249c963a39b5b8aa64442fc619c413439ab97762192
7
+ data.tar.gz: 36f4eb0fd7a2fca69f5c3a132bfd0cb7a11fdb5450864b57126ef89439d8511b887b9ff731d91c0267973659745d2346a7825dca49bbab841905032742d33d77
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [3.0.20](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.19...vite_rails@3.0.20) (2026-01-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Early Hint links should be separated by a comma ([#576](https://github.com/ElMassimo/vite_ruby/issues/576)) ([6fd220a](https://github.com/ElMassimo/vite_ruby/commit/6fd220abdedf4b36089359565867e61251d8b605))
7
+
8
+
9
+
1
10
  ## [3.0.19](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.18...vite_rails@3.0.19) (2024-11-05)
2
11
 
3
12
 
data/lib/tasks/vite.rake CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'vite_ruby'
3
+ require "vite_ruby"
4
4
  ViteRuby.install_tasks
5
- Rake::Task['vite:verify_install'].enhance([:environment]) if Gem.loaded_specs['rails']
5
+ Rake::Task["vite:verify_install"].enhance([:environment]) if Gem.loaded_specs["rails"]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'vite_rails'
3
+ require "vite_rails"
4
4
 
5
5
  module ViteRails::CLI
6
6
  end
@@ -13,44 +13,44 @@ module ViteRails::CLI::Build
13
13
 
14
14
  # Internal: Attempts to initialize the Rails application.
15
15
  def ensure_rails_init
16
- require File.expand_path('config/environment', Dir.pwd)
16
+ require File.expand_path("config/environment", Dir.pwd)
17
17
  rescue StandardError, LoadError => error
18
- $stderr << "Unable to initialize Rails application before Vite build:\n\n\t#{ error.message }\n\n"
18
+ $stderr << "Unable to initialize Rails application before Vite build:\n\n\t#{error.message}\n\n"
19
19
  end
20
20
  end
21
21
 
22
22
  # Internal: Extends the base installation script from Vite Ruby to work for a
23
23
  # typical Rails app.
24
24
  module ViteRails::CLI::Install
25
- RAILS_TEMPLATES = Pathname.new(File.expand_path('../../templates', __dir__))
25
+ RAILS_TEMPLATES = Pathname.new(File.expand_path("../../templates", __dir__))
26
26
 
27
27
  # Override: Setup a typical apps/web Hanami app to use Vite.
28
28
  def setup_app_files
29
- cp RAILS_TEMPLATES.join('config/rails-vite.json'), config.config_path
29
+ cp RAILS_TEMPLATES.join("config/rails-vite.json"), config.config_path
30
30
  if dir = %w[app/javascript app/packs].find { |path| root.join(path).exist? }
31
- replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "#{ dir }",)
31
+ replace_first_line config.config_path, "app/frontend", %( "sourceCodeDir": "#{dir}",)
32
32
  end
33
- setup_content_security_policy root.join('config/initializers/content_security_policy.rb')
34
- append root.join('Procfile.dev'), 'web: bin/rails s'
33
+ setup_content_security_policy root.join("config/initializers/content_security_policy.rb")
34
+ append root.join("Procfile.dev"), "web: bin/rails s"
35
35
  end
36
36
 
37
37
  # Internal: Configure CSP rules that allow to load @vite/client correctly.
38
38
  def setup_content_security_policy(csp_file)
39
39
  return unless csp_file.exist?
40
40
 
41
- inject_line_after csp_file, 'policy.script_src', <<~CSP
41
+ inject_line_after csp_file, "policy.script_src", <<~CSP
42
42
  # You may need to enable this in production as well depending on your setup.
43
43
  # policy.script_src *policy.script_src, :blob if Rails.env.test?
44
44
  CSP
45
- inject_line_after csp_file, 'policy.connect_src', <<~CSP
45
+ inject_line_after csp_file, "policy.connect_src", <<~CSP
46
46
  # Allow @vite/client to hot reload changes in development
47
47
  # policy.connect_src *policy.connect_src, "ws://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
48
48
  CSP
49
- inject_line_after csp_file, 'policy.script_src', <<~CSP
49
+ inject_line_after csp_file, "policy.script_src", <<~CSP
50
50
  # Allow @vite/client to hot reload javascript changes in development
51
51
  # policy.script_src *policy.script_src, :unsafe_eval, "http://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
52
52
  CSP
53
- inject_line_after csp_file, 'policy.style_src', <<~CSP
53
+ inject_line_after csp_file, "policy.style_src", <<~CSP
54
54
  # Allow @vite/client to hot reload style changes in development
55
55
  # policy.style_src *policy.style_src, :unsafe_inline if Rails.env.development?
56
56
  CSP
@@ -58,12 +58,12 @@ module ViteRails::CLI::Install
58
58
 
59
59
  # Override: Create a sample JS file and attempt to inject it in an HTML template.
60
60
  def install_sample_files
61
- unless config.resolved_entrypoints_dir.join('application.js').exist?
62
- cp RAILS_TEMPLATES.join('entrypoints/application.js'), config.resolved_entrypoints_dir.join('application.js')
61
+ unless config.resolved_entrypoints_dir.join("application.js").exist?
62
+ cp RAILS_TEMPLATES.join("entrypoints/application.js"), config.resolved_entrypoints_dir.join("application.js")
63
63
  end
64
64
 
65
- if (layout_file = root.join('app/views/layouts/application.html.erb')).exist?
66
- inject_line_before layout_file, '</head>', <<-HTML
65
+ if (layout_file = root.join("app/views/layouts/application.html.erb")).exist?
66
+ inject_line_before layout_file, "</head>", <<-HTML
67
67
  <%= vite_client_tag %>
68
68
  <%= vite_javascript_tag 'application' %>
69
69
  <!--
@@ -5,7 +5,7 @@ private
5
5
 
6
6
  # Override: Default values for a Rails application.
7
7
  def config_defaults
8
- require 'rails'
8
+ require "rails"
9
9
  asset_host = Rails.application&.config&.action_controller&.asset_host
10
10
  super(
11
11
  asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/railtie'
3
+ require "rails/railtie"
4
4
 
5
5
  class ViteRails::Engine < Rails::Engine
6
- initializer 'vite_rails.proxy' do |app|
6
+ initializer "vite_rails.proxy" do |app|
7
7
  app.middleware.insert_before 0, ViteRuby::DevServerProxy, ssl_verify_none: true if ViteRuby.run_proxy?
8
8
  end
9
9
 
10
- initializer 'vite_rails.helper' do
10
+ initializer "vite_rails.helper" do
11
11
  ActiveSupport.on_load(:action_controller) do
12
12
  ActionController::Base.helper(ViteRails::TagHelpers)
13
13
  end
@@ -17,25 +17,25 @@ class ViteRails::Engine < Rails::Engine
17
17
  end
18
18
  end
19
19
 
20
- initializer 'vite_rails.logger' do
20
+ initializer "vite_rails.logger" do
21
21
  config.after_initialize do
22
22
  ViteRuby.instance.logger = Rails.logger
23
23
  end
24
24
  end
25
25
 
26
- initializer 'vite_rails.bootstrap' do
26
+ initializer "vite_rails.bootstrap" do
27
27
  if defined?(Rails::Server) || defined?(Rails::Console)
28
28
  ViteRuby.bootstrap
29
29
  if defined?(Spring)
30
- require 'spring/watcher'
30
+ require "spring/watcher"
31
31
  Spring.after_fork { ViteRuby.bootstrap }
32
32
  Spring.watch(ViteRuby.config.config_path)
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
- initializer 'vite_rails.set_source' do |app|
37
+ initializer "vite_rails.set_source" do |app|
38
38
  source_dir = ViteRuby.config.root.join(ViteRuby.config.source_code_dir)
39
- app.config.javascript_path = source_dir.relative_path_from(Rails.root.join('app')).to_s
39
+ app.config.javascript_path = source_dir.relative_path_from(Rails.root.join("app")).to_s
40
40
  end
41
41
  end
@@ -3,10 +3,10 @@
3
3
  # Public: Allows to render HTML tags for scripts and styles processed by Vite.
4
4
  module ViteRails::TagHelpers
5
5
  # Public: Renders a script tag for vite/client to enable HMR in development.
6
- def vite_client_tag(crossorigin: 'anonymous', **options)
6
+ def vite_client_tag(crossorigin: "anonymous", **options)
7
7
  return unless src = vite_manifest.vite_client_src
8
8
 
9
- javascript_include_tag(src, type: 'module', extname: false, crossorigin: crossorigin, **options)
9
+ javascript_include_tag(src, type: "module", extname: false, crossorigin: crossorigin, **options)
10
10
  end
11
11
 
12
12
  # Public: Renders a script tag to enable HMR with React Refresh.
@@ -36,13 +36,13 @@ module ViteRails::TagHelpers
36
36
 
37
37
  # Public: Renders a <script> tag for the specified Vite entrypoints.
38
38
  def vite_javascript_tag(*names,
39
- type: 'module',
40
- asset_type: :javascript,
41
- skip_preload_tags: false,
42
- skip_style_tags: false,
43
- crossorigin: 'anonymous',
44
- media: 'screen',
45
- **options)
39
+ type: "module",
40
+ asset_type: :javascript,
41
+ skip_preload_tags: false,
42
+ skip_style_tags: false,
43
+ crossorigin: "anonymous",
44
+ media: "screen",
45
+ **options)
46
46
  entries = vite_manifest.resolve_entries(*names, type: asset_type)
47
47
  tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
48
48
  tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin, **options) unless skip_preload_tags
@@ -72,8 +72,8 @@ module ViteRails::TagHelpers
72
72
  def vite_image_tag(name, **options)
73
73
  if options[:srcset] && !options[:srcset].is_a?(String)
74
74
  options[:srcset] = options[:srcset].map do |src_name, size|
75
- "#{ vite_asset_path(src_name) } #{ size }"
76
- end.join(', ')
75
+ "#{vite_asset_path(src_name)} #{size}"
76
+ end.join(", ")
77
77
  end
78
78
 
79
79
  image_tag(vite_asset_path(name), options)
@@ -81,8 +81,8 @@ module ViteRails::TagHelpers
81
81
 
82
82
  # Public: Renders a <picture> tag with one or more Vite asset sources.
83
83
  def vite_picture_tag(*sources, &block)
84
- unless Rails.gem_version >= Gem::Version.new('7.1.0')
85
- raise NotImplementedError, '`vite_picture_tag` is only available for Rails 7.1 or above.'
84
+ unless Rails.gem_version >= Gem::Version.new("7.1.0")
85
+ raise NotImplementedError, "`vite_picture_tag` is only available for Rails 7.1 or above."
86
86
  end
87
87
 
88
88
  sources.flatten!
@@ -105,12 +105,12 @@ private
105
105
  asset_paths = sources.map { |source| path_to_asset(source, **url_options) }
106
106
  try(:request).try(
107
107
  :send_early_hints,
108
- 'Link' => asset_paths.map { |href|
109
- %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin })
110
- }.join("\n"),
108
+ "Link" => asset_paths.map { |href|
109
+ %(<#{href}>; rel=modulepreload; as=script; crossorigin=#{crossorigin})
110
+ }.join(","),
111
111
  )
112
112
  asset_paths.map { |href|
113
- tag.link(rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin, **options)
113
+ tag.link(rel: "modulepreload", href: href, as: "script", crossorigin: crossorigin, **options)
114
114
  }.join("\n").html_safe
115
115
  end
116
116
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViteRails
4
- VERSION = '3.0.19'
4
+ VERSION = "3.0.20"
5
5
  end
data/lib/vite_rails.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'vite_ruby'
3
+ require "vite_ruby"
4
4
 
5
- require 'vite_rails/version'
6
- require 'vite_rails/config'
7
- require 'vite_rails/tag_helpers'
8
- require 'vite_rails/engine' if defined?(Rails)
5
+ require "vite_rails/version"
6
+ require "vite_rails/config"
7
+ require "vite_rails/tag_helpers"
8
+ require "vite_rails/engine" if defined?(Rails)
@@ -22,7 +22,7 @@ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify
22
22
  // ActiveStorage.start()
23
23
  //
24
24
  // // Import all channels.
25
- // const channels = import.meta.globEager('./**/*_channel.js')
25
+ // const channels = import.meta.glob('./**/*_channel.js', { eager: true })
26
26
 
27
27
  // Example: Import a stylesheet in app/frontend/index.css
28
28
  // import '~/index.css'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.19
4
+ version: 3.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2026-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -88,8 +88,9 @@ homepage: https://github.com/ElMassimo/vite_ruby
88
88
  licenses:
89
89
  - MIT
90
90
  metadata:
91
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@3.0.19/vite_rails
92
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@3.0.19/vite_rails/CHANGELOG.md
91
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@3.0.20/vite_rails
92
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@3.0.20/vite_rails/CHANGELOG.md
93
+ rubygems_mfa_required: 'true'
93
94
  post_install_message:
94
95
  rdoc_options: []
95
96
  require_paths:
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
108
  requirements: []
108
- rubygems_version: 3.3.7
109
+ rubygems_version: 3.2.32
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: Use Vite in Rails and bring joy to your JavaScript experience