vite_rails 3.10.0 → 4.0.0.alpha1

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: d820706d13e470c21682a486091d851a9fc52ba5df2a90793bc75395eb481757
4
- data.tar.gz: 9c223574257301bbc34998347bc1b2181873ca2f1210558b16aaa7fad49e5881
3
+ metadata.gz: b468faa93a51c963d70a987a45f6dbb605c3854dd9ec188d40f0a93c085508d5
4
+ data.tar.gz: a04b6b5f89227b70c1d82e3a649ee1b6d423beedc1e1408126528962ba2962a0
5
5
  SHA512:
6
- metadata.gz: 3c48cd977f395272bde70643fed94f1b16ea99d62e1279051939ec9b1614448ee64abf31745ca04a80320384445fefa7235b49ee460f2be7992fa7fe154e627e
7
- data.tar.gz: eb8f2eefae91019649127d0ecd50b3699d9ffa80a5be68df2758d7ec3813cfacc7e017319c834b921b53f0c85ae81b764d59a2b3323e5a8ba5fcd5430ecb9e72
6
+ metadata.gz: 5d5d14601db1a186747566549bd620c1d6c534fe111a2dd9712694743ae3ba691200c56628f1a9fd08c0edbbce68da81ecd28d7e338b8fac215f2bf4b1c99373
7
+ data.tar.gz: 305be4fa2c036e0b8ef509b38fb50985f7c3a8ff8caedc608b919b436a048ffe1d06c5a136a0183ebd80faf5946882ae0a76814eac809e017477c22f7bcbbe24
data/CHANGELOG.md CHANGED
@@ -1,147 +1,9 @@
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
-
20
- ## [3.0.19](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.18...vite_rails@3.0.19) (2024-11-05)
21
-
22
-
23
- ### Bug Fixes
24
-
25
- * respect host and protocol options in vite_preload_tag ([#413](https://github.com/ElMassimo/vite_ruby/issues/413)) ([bcd8151](https://github.com/ElMassimo/vite_ruby/commit/bcd8151e77e90b5c219650db604ccf6bb6617720))
26
-
27
-
28
-
29
- ## [3.0.18](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.17...vite_rails@3.0.18) (2024-10-21)
30
-
31
-
32
-
33
- ## [3.0.17](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.16...vite_rails@3.0.17) (2023-10-05)
1
+ # [](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.5...vite_rails@) (2022-01-18)
34
2
 
35
3
 
36
4
  ### Features
37
5
 
38
- * add vite_picture_tag for Rails 7.1 ([#409](https://github.com/ElMassimo/vite_ruby/issues/409)) ([4e3762a](https://github.com/ElMassimo/vite_ruby/commit/4e3762a978b7879206dbc48137ba525d0d0ad971))
39
-
40
-
41
-
42
- ## [3.0.16](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.15...vite_rails@3.0.16) (2023-09-22)
43
-
44
-
45
- ### Bug Fixes
46
-
47
- * emit a single early hint per entrypoint in `vite_preload_tag` ([#402](https://github.com/ElMassimo/vite_ruby/issues/402)) ([3f9a60b](https://github.com/ElMassimo/vite_ruby/commit/3f9a60b4bb28858b8460b5fc302ad352a03ba002))
48
-
49
-
50
-
51
- ## [3.0.15](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.14...vite_rails@3.0.15) (2023-06-19)
52
-
53
-
54
- ### Features
55
-
56
- * add nonce by default to react refresh tag (close [#249](https://github.com/ElMassimo/vite_ruby/issues/249)) ([a31f0a9](https://github.com/ElMassimo/vite_ruby/commit/a31f0a97588568a964b52005beee63217c7bcfa9))
57
- * Use javascript_tag helper for vite_react_refresh_tag ([#372](https://github.com/ElMassimo/vite_ruby/issues/372)) ([238c6bd](https://github.com/ElMassimo/vite_ruby/commit/238c6bd211c0fafaa6170f0bdd631a0f6e41d992)), closes [#249](https://github.com/ElMassimo/vite_ruby/issues/249)
58
-
59
-
60
-
61
- ## [3.0.14](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.13...vite_rails@3.0.14) (2023-02-08)
62
-
63
-
64
- ### Features
65
-
66
- * allow javascript_include_tag options to vite_client_tag ([#337](https://github.com/ElMassimo/vite_ruby/issues/337)) ([417bcf3](https://github.com/ElMassimo/vite_ruby/commit/417bcf38366dd26901eb87cedd80d01118d7936f))
67
- * make vite_client_tag crossorigin: "anonymous" by default ([404a15a](https://github.com/ElMassimo/vite_ruby/commit/404a15a70c9d4fcd774735045c0d58d3e2aa37f2))
68
-
69
-
70
-
71
- ## [3.0.13](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.12...vite_rails@3.0.13) (2022-11-13)
72
-
73
-
74
- ### Bug Fixes
75
-
76
- * avoid removing double extension for non-preprocessor assets ([#301](https://github.com/ElMassimo/vite_ruby/issues/301)) ([2024f62](https://github.com/ElMassimo/vite_ruby/commit/2024f62af917cabcb817c32a5fbbe709d477c19f))
77
-
78
-
79
-
80
- ## [3.0.12](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.11...vite_rails@3.0.12) (2022-08-12)
81
-
82
-
83
- ### Bug Fixes
84
-
85
- * ensure rails app is initialized before inferring config ([#240](https://github.com/ElMassimo/vite_ruby/issues/240)) ([3ddc2bc](https://github.com/ElMassimo/vite_ruby/commit/3ddc2bc7873f06b6dd8e58e7c6b4e8a7fd8833f1))
86
-
87
-
88
- ### Features
89
-
90
- * allow framework-specific libraries to extend the CLI ([a0ed66f](https://github.com/ElMassimo/vite_ruby/commit/a0ed66fe64fb2549cecc358ccd60c82be44255aa))
91
-
92
-
93
-
94
- ## [3.0.11](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.10...vite_rails@3.0.11) (2022-08-11)
95
-
96
-
97
- ### Bug Fixes
98
-
99
- * use javascript_include_tag in vite_client_tag ([#238](https://github.com/ElMassimo/vite_ruby/issues/238)) ([3d8b366](https://github.com/ElMassimo/vite_ruby/commit/3d8b3668b2f43dacbaf09127fa67a27767e03ffe))
100
-
101
-
102
-
103
- ## [3.0.10](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.9...vite_rails@3.0.10) (2022-06-15)
104
-
105
-
106
- ### Bug Fixes
107
-
108
- * symbol error on rake enhance call ([#218](https://github.com/ElMassimo/vite_ruby/issues/218)) ([5507156](https://github.com/ElMassimo/vite_ruby/commit/550715624ceb39e1ea5e845e73dcaf5557caa66f))
109
-
110
-
111
-
112
- ## [3.0.9](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.8...vite_rails@3.0.9) (2022-04-29)
113
-
114
-
115
- ### Features
116
-
117
- * add vite_asset_url helper ([#208](https://github.com/ElMassimo/vite_ruby/issues/208)) ([d269793](https://github.com/ElMassimo/vite_ruby/commit/d2697934b5a866ea5b14588b650a00dfe88454a3))
118
-
119
-
120
-
121
- ## [3.0.8](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.7...vite_rails@3.0.8) (2022-04-14)
122
-
123
-
124
- ### Bug Fixes
125
-
126
- * prevent error when using a proc in asset_host (close [#202](https://github.com/ElMassimo/vite_ruby/issues/202)) ([#203](https://github.com/ElMassimo/vite_ruby/issues/203)) ([cb23a81](https://github.com/ElMassimo/vite_ruby/commit/cb23a81037651ac01d993935f68cc526ec2c844d))
127
-
128
-
129
-
130
- ## [3.0.7](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.6...vite_rails@3.0.7) (2022-03-17)
131
-
132
-
133
- ### Bug Fixes
134
-
135
- * load rails environment before rake tasks (close [#193](https://github.com/ElMassimo/vite_ruby/issues/193)) ([72afbc7](https://github.com/ElMassimo/vite_ruby/commit/72afbc7ab5ca33833e9330954499bcf460fd7669))
136
-
137
-
138
-
139
- ## [3.0.6](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.5...vite_rails@3.0.6) (2022-02-04)
140
-
141
-
142
- ### Bug Fixes
143
-
144
- * don't add crossorigin to included stylesheet tags (close [#189](https://github.com/ElMassimo/vite_ruby/issues/189)) ([#190](https://github.com/ElMassimo/vite_ruby/issues/190)) ([575c731](https://github.com/ElMassimo/vite_ruby/commit/575c73192fb485e8844f67b821c856d1a09db8f5))
6
+ * **experimental:** add support for Subresource Integrity via vite-plugin-manifest-sri ([0b3142c](https://github.com/ElMassimo/vite_ruby/commit/0b3142cd9d569a5f56821f53cdade337779bb0c1))
145
7
 
146
8
 
147
9
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">
2
2
  <a href="https://vite-ruby.netlify.app/">
3
- <img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/logo.svg" width="120px"/>
3
+ <img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/docs/public/logo.svg" width="120px"/>
4
4
  </a>
5
5
 
6
6
  <br>
data/lib/tasks/vite.rake CHANGED
@@ -1,5 +1,4 @@
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"]
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViteRails::Config
4
- private
5
-
6
4
  # Override: Default values for a Rails application.
7
5
  def config_defaults
8
- require "rails"
9
- asset_host = Rails.application&.config&.action_controller&.asset_host
6
+ require 'rails'
10
7
  super(
11
- asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
8
+ asset_host: Rails.application&.config&.action_controller&.asset_host,
12
9
  mode: Rails.env.to_s,
13
10
  root: Rails.root || Dir.pwd,
14
11
  )
@@ -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
@@ -1,56 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "vite_rails"
4
-
5
- module ViteRails::CLI
6
- end
7
-
8
- module ViteRails::CLI::Build
9
- def call(**options)
10
- ensure_rails_init
11
- super
12
- end
13
-
14
- # Internal: Attempts to initialize the Rails application.
15
- def ensure_rails_init
16
- require File.expand_path("config/environment", Dir.pwd)
17
- rescue StandardError, LoadError => error
18
- $stderr << "Unable to initialize Rails application before Vite build:\n\n\t#{error.message}\n\n"
19
- end
20
- end
3
+ require 'vite_rails'
21
4
 
22
5
  # Internal: Extends the base installation script from Vite Ruby to work for a
23
6
  # typical Rails app.
24
- module ViteRails::CLI::Install
25
- RAILS_TEMPLATES = Pathname.new(File.expand_path("../../templates", __dir__))
7
+ module ViteRails::Installation
8
+ RAILS_TEMPLATES = Pathname.new(File.expand_path('../../templates', __dir__))
26
9
 
27
- # Override: Setup a typical apps/web Rails app to use Vite.
10
+ # Override: Setup a typical apps/web Hanami app to use Vite.
28
11
  def setup_app_files
29
- cp RAILS_TEMPLATES.join("config/rails-vite.json"), config.config_path
12
+ cp RAILS_TEMPLATES.join('config/rails-vite.json'), config.config_path
30
13
  if dir = %w[app/javascript app/packs].find { |path| root.join(path).exist? }
31
- replace_first_line config.config_path, "app/frontend", %( "sourceCodeDir": "#{dir}",)
14
+ replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "#{ dir }",)
32
15
  end
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:"
16
+ setup_content_security_policy root.join('config/initializers/content_security_policy.rb')
17
+ append root.join('Procfile.dev'), 'web: bin/rails s'
35
18
  end
36
19
 
37
20
  # Internal: Configure CSP rules that allow to load @vite/client correctly.
38
21
  def setup_content_security_policy(csp_file)
39
22
  return unless csp_file.exist?
40
23
 
41
- inject_line_after csp_file, "policy.script_src", <<~CSP
24
+ inject_line_after csp_file, 'policy.script_src', <<~CSP
42
25
  # You may need to enable this in production as well depending on your setup.
43
26
  # policy.script_src *policy.script_src, :blob if Rails.env.test?
44
27
  CSP
45
- inject_line_after csp_file, "policy.connect_src", <<~CSP
28
+ inject_line_after csp_file, 'policy.connect_src', <<~CSP
46
29
  # Allow @vite/client to hot reload changes in development
47
30
  # policy.connect_src *policy.connect_src, "ws://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
48
31
  CSP
49
- inject_line_after csp_file, "policy.script_src", <<~CSP
32
+ inject_line_after csp_file, 'policy.script_src', <<~CSP
50
33
  # Allow @vite/client to hot reload javascript changes in development
51
34
  # policy.script_src *policy.script_src, :unsafe_eval, "http://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
52
35
  CSP
53
- inject_line_after csp_file, "policy.style_src", <<~CSP
36
+ inject_line_after csp_file, 'policy.style_src', <<~CSP
54
37
  # Allow @vite/client to hot reload style changes in development
55
38
  # policy.style_src *policy.style_src, :unsafe_inline if Rails.env.development?
56
39
  CSP
@@ -58,12 +41,12 @@ module ViteRails::CLI::Install
58
41
 
59
42
  # Override: Create a sample JS file and attempt to inject it in an HTML template.
60
43
  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")
44
+ unless config.resolved_entrypoints_dir.join('application.js').exist?
45
+ cp RAILS_TEMPLATES.join('entrypoints/application.js'), config.resolved_entrypoints_dir.join('application.js')
63
46
  end
64
47
 
65
- if (layout_file = root.join("app/views/layouts/application.html.erb")).exist?
66
- inject_line_before layout_file, "</head>", <<-HTML
48
+ if (layout_file = root.join('app/views/layouts/application.html.erb')).exist?
49
+ inject_line_before layout_file, '</head>', <<-HTML
67
50
  <%= vite_client_tag %>
68
51
  <%= vite_javascript_tag 'application' %>
69
52
  <!--
@@ -80,5 +63,4 @@ module ViteRails::CLI::Install
80
63
  end
81
64
  end
82
65
 
83
- ViteRuby::CLI::Build.prepend(ViteRails::CLI::Build)
84
- ViteRuby::CLI::Install.prepend(ViteRails::CLI::Install)
66
+ ViteRuby::CLI::Install.prepend(ViteRails::Installation)
@@ -3,19 +3,15 @@
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
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
+ tag.script(src: src, type: 'module')
10
10
  end
11
11
 
12
12
  # Public: Renders a script tag to enable HMR with React Refresh.
13
- def vite_react_refresh_tag(**options)
14
- return unless react_preamble_code = vite_manifest.react_preamble_code
15
-
16
- options[:nonce] = true if Rails::VERSION::MAJOR >= 6 && !options.key?(:nonce)
17
-
18
- javascript_tag(react_preamble_code.html_safe, type: :module, **options)
13
+ def vite_react_refresh_tag
14
+ vite_manifest.react_refresh_preamble&.html_safe
19
15
  end
20
16
 
21
17
  # Public: Resolves the path for the specified Vite asset.
@@ -26,28 +22,28 @@ module ViteRails::TagHelpers
26
22
  path_to_asset vite_manifest.path_for(name, **options)
27
23
  end
28
24
 
29
- # Public: Resolves the url for the specified Vite asset.
30
- #
31
- # Example:
32
- # <%= vite_asset_url 'calendar.css' %> # => "https://example.com/vite/assets/calendar-1016838bab065ae1e122.css"
33
- def vite_asset_url(name, **options)
34
- url_to_asset vite_manifest.path_for(name, **options)
35
- end
36
-
37
25
  # Public: Renders a <script> tag for the specified Vite entrypoints.
38
26
  def vite_javascript_tag(*names,
39
- type: "module",
40
- asset_type: :javascript,
41
- skip_preload_tags: false,
42
- skip_style_tags: false,
43
- crossorigin: "",
44
- media: "screen",
45
- **options)
27
+ type: 'module',
28
+ asset_type: :javascript,
29
+ integrity: false,
30
+ skip_preload_tags: false,
31
+ skip_style_tags: false,
32
+ crossorigin: 'anonymous',
33
+ media: 'screen',
34
+ **options)
46
35
  entries = vite_manifest.resolve_entries(*names, type: asset_type)
47
- tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
48
- tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin, **options) unless skip_preload_tags
36
+ tags = ''.html_safe
37
+
38
+ entries.fetch(:main).each do |src, attrs|
39
+ tags << javascript_include_tag(src, crossorigin: crossorigin, type: type, extname: false, **attrs, **options)
40
+ end
49
41
 
50
- options[:extname] = false if Rails::VERSION::MAJOR >= 7
42
+ unless skip_preload_tags
43
+ entries.fetch(:imports).each do |href, attrs|
44
+ tags << vite_preload_tag(href, crossorigin: crossorigin, **attrs, **options)
45
+ end
46
+ end
51
47
 
52
48
  tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, crossorigin: crossorigin, **options) unless skip_style_tags
53
49
 
@@ -60,38 +56,25 @@ module ViteRails::TagHelpers
60
56
  end
61
57
 
62
58
  # Public: Renders a <link> tag for the specified Vite entrypoints.
63
- def vite_stylesheet_tag(*names, **options)
64
- style_paths = names.map { |name| vite_asset_path(name, type: :stylesheet) }
65
-
66
- options[:extname] = false if Rails::VERSION::MAJOR >= 7
67
-
68
- stylesheet_link_tag(*style_paths, **options)
59
+ def vite_stylesheet_tag(*names, integrity: false, **options)
60
+ ''.html_safe.tap do |tags|
61
+ vite_manifest.resolve_entries(*names, type: :stylesheet).fetch(:main).each do |href, attrs|
62
+ tags << stylesheet_link_tag(href, **attrs, **options)
63
+ end
64
+ end
69
65
  end
70
66
 
71
67
  # Public: Renders an <img> tag for the specified Vite asset.
72
68
  def vite_image_tag(name, **options)
73
69
  if options[:srcset] && !options[:srcset].is_a?(String)
74
70
  options[:srcset] = options[:srcset].map do |src_name, size|
75
- "#{vite_asset_path(src_name)} #{size}"
76
- end.join(", ")
71
+ "#{ vite_asset_path(src_name) } #{ size }"
72
+ end.join(', ')
77
73
  end
78
74
 
79
75
  image_tag(vite_asset_path(name), options)
80
76
  end
81
77
 
82
- # Public: Renders a <picture> tag with one or more Vite asset sources.
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."
86
- end
87
-
88
- sources.flatten!
89
- options = sources.extract_options!
90
-
91
- vite_sources = sources.map { |src| vite_asset_path(src) }
92
- picture_tag(*vite_sources, options, &block)
93
- end
94
-
95
78
  private
96
79
 
97
80
  # Internal: Returns the current manifest loaded by Vite Ruby.
@@ -100,17 +83,13 @@ private
100
83
  end
101
84
 
102
85
  # Internal: Renders a modulepreload link tag.
103
- def vite_preload_tag(*sources, crossorigin:, **options)
104
- url_options = options.extract!(:host, :protocol)
105
- asset_paths = sources.map { |source| path_to_asset(source, **url_options) }
106
- try(:request).try(
107
- :send_early_hints,
108
- "Link" => asset_paths.map { |href|
109
- %(<#{href}>; rel=modulepreload; as=script; crossorigin=#{crossorigin})
110
- }.join(","),
111
- )
112
- asset_paths.map { |href|
113
- tag.link(rel: "modulepreload", href: href, as: "script", crossorigin: crossorigin, **options)
114
- }.join("\n").html_safe
86
+ def vite_preload_tag(source, crossorigin:, **options)
87
+ href = path_to_asset(source)
88
+ try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }).tap { |hint|
89
+ if integrity = options[:integrity]
90
+ hint << "; integrity: #{ integrity }"
91
+ end
92
+ })
93
+ tag.link(rel: 'modulepreload', href: href, as: 'script', type: 'module', crossorigin: crossorigin, **options)
115
94
  end
116
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViteRails
4
- VERSION = "3.10.0"
4
+ VERSION = '4.0.0.alpha1'
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.glob('./**/*_channel.js', { eager: true })
25
+ // const channels = import.meta.globEager('./**/*_channel.js')
26
26
 
27
27
  // Example: Import a stylesheet in app/frontend/index.css
28
28
  // import '~/index.css'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 4.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: railties
@@ -18,7 +19,7 @@ dependencies:
18
19
  version: '5.1'
19
20
  - - "<"
20
21
  - !ruby/object:Gem::Version
21
- version: '9'
22
+ version: '8'
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,27 +29,21 @@ dependencies:
28
29
  version: '5.1'
29
30
  - - "<"
30
31
  - !ruby/object:Gem::Version
31
- version: '9'
32
+ version: '8'
32
33
  - !ruby/object:Gem::Dependency
33
34
  name: vite_ruby
34
35
  requirement: !ruby/object:Gem::Requirement
35
36
  requirements:
36
- - - ">="
37
- - !ruby/object:Gem::Version
38
- version: 3.2.2
39
37
  - - "~>"
40
38
  - !ruby/object:Gem::Version
41
- version: '3.0'
39
+ version: 4.0.0.alpha1
42
40
  type: :runtime
43
41
  prerelease: false
44
42
  version_requirements: !ruby/object:Gem::Requirement
45
43
  requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 3.2.2
49
44
  - - "~>"
50
45
  - !ruby/object:Gem::Version
51
- version: '3.0'
46
+ version: 4.0.0.alpha1
52
47
  - !ruby/object:Gem::Dependency
53
48
  name: spring
54
49
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +58,7 @@ dependencies:
63
58
  - - "~>"
64
59
  - !ruby/object:Gem::Version
65
60
  version: '2.1'
61
+ description:
66
62
  email:
67
63
  - maximomussini@gmail.com
68
64
  executables: []
@@ -74,9 +70,9 @@ files:
74
70
  - README.md
75
71
  - lib/tasks/vite.rake
76
72
  - lib/vite_rails.rb
77
- - lib/vite_rails/cli.rb
78
73
  - lib/vite_rails/config.rb
79
74
  - lib/vite_rails/engine.rb
75
+ - lib/vite_rails/installation.rb
80
76
  - lib/vite_rails/tag_helpers.rb
81
77
  - lib/vite_rails/version.rb
82
78
  - templates/Procfile.dev
@@ -86,9 +82,9 @@ homepage: https://github.com/ElMassimo/vite_ruby
86
82
  licenses:
87
83
  - MIT
88
84
  metadata:
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'
85
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@4.0.0.alpha1/vite_rails
86
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@4.0.0.alpha1/vite_rails/CHANGELOG.md
87
+ post_install_message:
92
88
  rdoc_options: []
93
89
  require_paths:
94
90
  - lib
@@ -99,11 +95,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
95
  version: '2.5'
100
96
  required_rubygems_version: !ruby/object:Gem::Requirement
101
97
  requirements:
102
- - - ">="
98
+ - - ">"
103
99
  - !ruby/object:Gem::Version
104
- version: '0'
100
+ version: 1.3.1
105
101
  requirements: []
106
- rubygems_version: 3.6.9
102
+ rubygems_version: 3.2.32
103
+ signing_key:
107
104
  specification_version: 4
108
105
  summary: Use Vite in Rails and bring joy to your JavaScript experience
109
106
  test_files: []