vite_rails_legacy 3.0.4 → 3.1.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/tasks/vite.rake +1 -1
- data/lib/vite_rails_legacy/config.rb +2 -2
- data/lib/vite_rails_legacy/engine.rb +7 -7
- data/lib/vite_rails_legacy/installation.rb +9 -9
- data/lib/vite_rails_legacy/tag_helpers.rb +20 -12
- data/lib/vite_rails_legacy/version.rb +1 -1
- data/lib/vite_rails_legacy.rb +6 -6
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1039841e84fe521267ebea3233102d6153dc3890ca8f07c882f1eb2143e4c307
|
4
|
+
data.tar.gz: 1de43a51b7ab11124afef02ea784d2b5f0871bbfc4ad10a5167e33019dce0927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0841767bac11afadf2f764601f555bf90f378800f5d2ed33e7eeda7227245e60eade0f605c1197bffe9a0d237795429278d4fe4bbfd463773db6472f7103bc6
|
7
|
+
data.tar.gz: b5805e3cfaa7475c7da405e359355a21842b25c7ac70131b76eacd4ea80db6cf37b05f0d23d1a6332ff4dd3e3049af070a6322c652f32b7538e2f8516cbd43e2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# [3.1.0](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@3.0.5...vite_rails_legacy@3.1.0) (2024-11-06)
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## [3.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@3.0.4...vite_rails_legacy@3.0.5) (2022-04-29)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* add vite_asset_url helper ([#208](https://github.com/ElMassimo/vite_ruby/issues/208)) ([d269793](https://github.com/ElMassimo/vite_ruby/commit/d2697934b5a866ea5b14588b650a00dfe88454a3))
|
11
|
+
|
12
|
+
|
13
|
+
|
1
14
|
## [3.0.4](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@3.0.3...vite_rails_legacy@3.0.4) (2022-04-14)
|
2
15
|
|
3
16
|
|
data/lib/tasks/vite.rake
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module ViteRailsLegacy::Config
|
4
4
|
# Override: Default values for a Rails application.
|
5
5
|
def config_defaults
|
6
|
-
require
|
6
|
+
require "rails"
|
7
7
|
asset_host = Rails.application&.config&.action_controller&.asset_host
|
8
8
|
super(
|
9
9
|
asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
|
@@ -13,5 +13,5 @@ module ViteRailsLegacy::Config
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
require
|
16
|
+
require "active_support/core_ext/hash"
|
17
17
|
ViteRuby::Config.singleton_class.prepend(ViteRailsLegacy::Config)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/railtie"
|
4
4
|
|
5
5
|
class ViteRailsLegacy::Engine < Rails::Engine
|
6
|
-
initializer
|
7
|
-
app.middleware.insert_before 0,
|
6
|
+
initializer "vite_rails.proxy" do |app|
|
7
|
+
app.middleware.insert_before 0, "ViteRuby::DevServerProxy", ssl_verify_none: true if ViteRuby.run_proxy?
|
8
8
|
end
|
9
9
|
|
10
|
-
initializer
|
10
|
+
initializer "vite_rails_legacy.helper" do
|
11
11
|
ActiveSupport.on_load(:action_controller) do
|
12
12
|
ActionController::Base.helper(ViteRailsLegacy::TagHelpers)
|
13
13
|
end
|
@@ -17,17 +17,17 @@ class ViteRailsLegacy::Engine < Rails::Engine
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
initializer
|
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
|
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
|
30
|
+
require "spring/watcher"
|
31
31
|
Spring.after_fork { ViteRuby.bootstrap }
|
32
32
|
Spring.watch(ViteRuby.config.config_path)
|
33
33
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "vite_rails_legacy"
|
4
4
|
|
5
5
|
# Internal: Extends the base installation script from Vite Ruby to work for a
|
6
6
|
# typical Rails app.
|
7
7
|
module ViteRailsLegacy::Installation
|
8
|
-
RAILS_TEMPLATES = Pathname.new(File.expand_path(
|
8
|
+
RAILS_TEMPLATES = Pathname.new(File.expand_path("../../templates", __dir__))
|
9
9
|
|
10
10
|
# Override: Setup a typical apps/web Hanami app to use Vite.
|
11
11
|
def setup_app_files
|
12
|
-
cp RAILS_TEMPLATES.join(
|
13
|
-
if root.join(
|
14
|
-
replace_first_line config.config_path,
|
12
|
+
cp RAILS_TEMPLATES.join("config/rails-vite.json"), config.config_path
|
13
|
+
if root.join("app/javascript").exist?
|
14
|
+
replace_first_line config.config_path, "app/frontend", %( "sourceCodeDir": "app/javascript",)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
# Override: Create a sample JS file and attempt to inject it in an HTML template.
|
19
19
|
def install_sample_files
|
20
|
-
unless config.resolved_entrypoints_dir.join(
|
21
|
-
cp RAILS_TEMPLATES.join(
|
20
|
+
unless config.resolved_entrypoints_dir.join("application.js").exist?
|
21
|
+
cp RAILS_TEMPLATES.join("entrypoints/application.js"), config.resolved_entrypoints_dir.join("application.js")
|
22
22
|
end
|
23
23
|
|
24
|
-
if (layout_file = root.join(
|
25
|
-
inject_line_before layout_file,
|
24
|
+
if (layout_file = root.join("app/views/layouts/application.html.erb")).exist?
|
25
|
+
inject_line_before layout_file, "</head>", <<-HTML
|
26
26
|
<%= vite_client_tag %>
|
27
27
|
<%= vite_javascript_tag 'application' %>
|
28
28
|
<!--
|
@@ -6,7 +6,7 @@ module ViteRailsLegacy::TagHelpers
|
|
6
6
|
def vite_client_tag
|
7
7
|
return unless src = vite_manifest.vite_client_src
|
8
8
|
|
9
|
-
"<script#{
|
9
|
+
"<script#{tag_options({src: src, type: "module"}, escape: true)}></script>".html_safe
|
10
10
|
end
|
11
11
|
|
12
12
|
# Public: Renders a script tag to enable HMR with React Refresh.
|
@@ -22,15 +22,23 @@ module ViteRailsLegacy::TagHelpers
|
|
22
22
|
path_to_asset vite_manifest.path_for(name, **options)
|
23
23
|
end
|
24
24
|
|
25
|
+
# Public: Resolves the url for the specified Vite asset.
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# <%= vite_asset_url 'calendar.css' %> # => "https://example.com/vite/assets/calendar-1016838bab065ae1e122.css"
|
29
|
+
def vite_asset_url(name, **options)
|
30
|
+
url_to_asset vite_manifest.path_for(name, **options)
|
31
|
+
end
|
32
|
+
|
25
33
|
# Public: Renders a <script> tag for the specified Vite entrypoints.
|
26
34
|
def vite_javascript_tag(*names,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
type: "module",
|
36
|
+
asset_type: :javascript,
|
37
|
+
skip_preload_tags: false,
|
38
|
+
skip_style_tags: false,
|
39
|
+
crossorigin: "anonymous",
|
40
|
+
media: "screen",
|
41
|
+
**options)
|
34
42
|
entries = vite_manifest.resolve_entries(*names, type: asset_type)
|
35
43
|
tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
|
36
44
|
tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin, **options) unless skip_preload_tags
|
@@ -53,8 +61,8 @@ module ViteRailsLegacy::TagHelpers
|
|
53
61
|
def vite_image_tag(name, **options)
|
54
62
|
if options[:srcset] && !options[:srcset].is_a?(String)
|
55
63
|
options[:srcset] = options[:srcset].map do |src_name, size|
|
56
|
-
"#{
|
57
|
-
end.join(
|
64
|
+
"#{vite_asset_path(src_name)} #{size}"
|
65
|
+
end.join(", ")
|
58
66
|
end
|
59
67
|
|
60
68
|
image_tag(vite_asset_path(name), options)
|
@@ -71,8 +79,8 @@ private
|
|
71
79
|
def vite_preload_tag(*sources, crossorigin:, **options)
|
72
80
|
sources.map { |source|
|
73
81
|
href = path_to_asset(source)
|
74
|
-
try(:request).try(:send_early_hints,
|
75
|
-
tag(
|
82
|
+
try(:request).try(:send_early_hints, "Link" => %(<#{href}>; rel=modulepreload; as=script; crossorigin=#{crossorigin}))
|
83
|
+
tag("link", rel: "modulepreload", href: href, as: "script", crossorigin: crossorigin, **options)
|
76
84
|
}.join("\n").html_safe
|
77
85
|
end
|
78
86
|
end
|
data/lib/vite_rails_legacy.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "vite_ruby"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require "vite_rails_legacy/version"
|
6
|
+
require "vite_rails_legacy/config"
|
7
|
+
require "vite_rails_legacy/tag_helpers"
|
8
|
+
require "vite_rails_legacy/engine" if defined?(Rails)
|
9
9
|
|
10
10
|
# Active Support 4 does not support multiple arguments in append.
|
11
11
|
class Array
|
12
|
-
|
12
|
+
alias_method :append, :push
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_rails_legacy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
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:
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -61,8 +61,9 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
61
61
|
licenses:
|
62
62
|
- MIT
|
63
63
|
metadata:
|
64
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails_legacy@3.0
|
65
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails_legacy@3.0
|
64
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails_legacy@3.1.0/vite_rails_legacy
|
65
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails_legacy@3.1.0/vite_rails_legacy/CHANGELOG.md
|
66
|
+
rubygems_mfa_required: 'true'
|
66
67
|
post_install_message:
|
67
68
|
rdoc_options: []
|
68
69
|
require_paths:
|
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
- !ruby/object:Gem::Version
|
79
80
|
version: '0'
|
80
81
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
+
rubygems_version: 3.5.16
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: Use Vite in Rails 4 and bring joy to your JavaScript experience
|