vite_rails 3.0.19 → 3.10.0

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: d820706d13e470c21682a486091d851a9fc52ba5df2a90793bc75395eb481757
4
+ data.tar.gz: 9c223574257301bbc34998347bc1b2181873ca2f1210558b16aaa7fad49e5881
5
5
  SHA512:
6
- metadata.gz: ba27baf7621e86dc14fafd03b965e8f24c7aade5763ce68e94a044e93c047716cf674e2c738047e4ed17d961898e16571c80a568435a24b8c299509592d1630c
7
- data.tar.gz: d9918d6bc2f636882ac336ea29bcc66e603f654ddcc1002bb53b59026c6b066684b01b19c14ac5e957fc861162851119e05c5ff62d1e0ec093b84e907bc0c9f1
6
+ metadata.gz: 3c48cd977f395272bde70643fed94f1b16ea99d62e1279051939ec9b1614448ee64abf31745ca04a80320384445fefa7235b49ee460f2be7992fa7fe154e627e
7
+ data.tar.gz: eb8f2eefae91019649127d0ecd50b3699d9ffa80a5be68df2758d7ec3813cfacc7e017319c834b921b53f0c85ae81b764d59a2b3323e5a8ba5fcd5430ecb9e72
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [3.10.0](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.20...vite_rails@3.10.0) (2026-03-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add crossorigin attribute to style tag ([#544](https://github.com/ElMassimo/vite_ruby/issues/544)) ([d57495e](https://github.com/ElMassimo/vite_ruby/commit/d57495ea9f0bd87682d997c54d9b352b5b986799))
7
+ * Check if `web` entry already on `Procfile.dev` before appending it ([#542](https://github.com/ElMassimo/vite_ruby/issues/542)) ([4546cf4](https://github.com/ElMassimo/vite_ruby/commit/4546cf48cbef881b4b57deb0fd9e43440e9897f4))
8
+
9
+
10
+
11
+ ## [3.0.20](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.19...vite_rails@3.0.20) (2026-01-02)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * 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))
17
+
18
+
19
+
1
20
  ## [3.0.19](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.18...vite_rails@3.0.19) (2024-11-05)
2
21
 
3
22
 
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
- # Override: Setup a typical apps/web Hanami app to use Vite.
27
+ # Override: Setup a typical apps/web Rails 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_unless_present root.join("Procfile.dev"), "web: bin/rails s", pattern: "web:"
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,20 +36,20 @@ 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: "",
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
49
49
 
50
50
  options[:extname] = false if Rails::VERSION::MAJOR >= 7
51
51
 
52
- tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, **options) unless skip_style_tags
52
+ tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, crossorigin: crossorigin, **options) unless skip_style_tags
53
53
 
54
54
  tags
55
55
  end
@@ -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.10.0"
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,13 @@
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.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -64,7 +63,6 @@ dependencies:
64
63
  - - "~>"
65
64
  - !ruby/object:Gem::Version
66
65
  version: '2.1'
67
- description:
68
66
  email:
69
67
  - maximomussini@gmail.com
70
68
  executables: []
@@ -88,9 +86,9 @@ homepage: https://github.com/ElMassimo/vite_ruby
88
86
  licenses:
89
87
  - MIT
90
88
  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
93
- post_install_message:
89
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@3.10.0/vite_rails
90
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@3.10.0/vite_rails/CHANGELOG.md
91
+ rubygems_mfa_required: 'true'
94
92
  rdoc_options: []
95
93
  require_paths:
96
94
  - lib
@@ -105,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
103
  - !ruby/object:Gem::Version
106
104
  version: '0'
107
105
  requirements: []
108
- rubygems_version: 3.3.7
109
- signing_key:
106
+ rubygems_version: 3.6.9
110
107
  specification_version: 4
111
108
  summary: Use Vite in Rails and bring joy to your JavaScript experience
112
109
  test_files: []