vite_rails_legacy 2.0.4 → 2.0.9

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: 87c27797d77d602f6220218f07b535e38dfae9fecf9e1c93cdd91acaf5dac42f
4
- data.tar.gz: '08febaca3438f2e4ee8c7d7e07b1825b59cb1b4d7be24b67da95e13cabb8f007'
3
+ metadata.gz: 71a5c3315a379e4d0e970fa6391923fa4a528d1131f19b95ead5584628458550
4
+ data.tar.gz: 3cd45cafadc41a3b7a4d67d5c0a8b78a6e128746118611524441bcf3ef3c78c8
5
5
  SHA512:
6
- metadata.gz: 9463be6a5e20e7d7346d564db0ec25f20e20b090817b2092d8d5116ac982a16d7478e3bea4e6a7bcc34fe8604e7e30c36a6da30471400385cc2965eb4ff6cc8d
7
- data.tar.gz: 7c4a0c5d4000d73345017e9dee0079313b830d3cad7f4a6c90af53056932882d499183490272f580b935cc1f801e1bd76e1cfcfacae46be88315f970d9f41dee
6
+ metadata.gz: c817e395280938cafe40590b7a6aed6eabd0e4a6534a614db3e848dc888f30728f7410d64e0585b8257e2a25b632c35f9b5ccc5ed0801ec7dea9450859d2a5b3
7
+ data.tar.gz: 601ee2092abecfb6d1c729ea9d2631f900e99f68c0aeb40077899afd285a721374b0350cadd467162cf6f352bf05dd6217fb32fc05eb17443dfd1ade41f4d593
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## [2.0.9](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.8...vite_rails_legacy@2.0.9) (2021-04-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add helpers to enable HMR when using @vitejs/plugin-react-refresh ([a80f286](https://github.com/ElMassimo/vite_ruby/commit/a80f286d4305bbae29ea7cea42a4329a530f43fa))
7
+
8
+
9
+
10
+ ## [2.0.8](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.7...vite_rails_legacy@2.0.8) (2021-04-15)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Allow passing additional attributes to scripts and stylesheets. ([edf6019](https://github.com/ElMassimo/vite_ruby/commit/edf6019fa83646e413f36d289eac89bb2f8042a5))
16
+
17
+
18
+
19
+ ## [2.0.7](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.6...vite_rails_legacy@2.0.7) (2021-03-20)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Simplify installation of build dependencies by using package manager flags ([5c8bb62](https://github.com/ElMassimo/vite_ruby/commit/5c8bb625926f2ab1788a3e3a22aeafd7104984cb))
25
+
26
+
27
+
28
+ ## [2.0.6](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.5...vite_rails_legacy@2.0.6) (2021-03-19)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * Typo typecript -> typescript in tag helpers ([#38](https://github.com/ElMassimo/vite_ruby/issues/38)) ([3d375df](https://github.com/ElMassimo/vite_ruby/commit/3d375df8553c8542966ac912a38fe70b7d59ba74))
34
+
35
+
36
+
37
+ ## [2.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.4...vite_rails_legacy@2.0.5) (2021-03-18)
38
+
39
+ * Add more help text in the example entrypoints ([87d6f14](https://github.com/ElMassimo/vite_ruby/commit/87d6f14a59bba2667089bb952960dce059f36592))
40
+
1
41
  ## [2.0.4](https://github.com/ElMassimo/vite_ruby/compare/vite_rails_legacy@2.0.3...vite_rails_legacy@2.0.4) (2021-03-18)
2
42
 
3
43
 
data/lib/tasks/vite.rake CHANGED
@@ -1,20 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Set NODE_ENV before installation, so that Rails installs JS build dependencies
4
- # on servers that precompile assets.
5
- installation_tasks = ['yarn:install', 'webpacker:yarn_install'].select { |name| Rake::Task.task_defined?(name) }.each do |name|
6
- Rake::Task[name].enhance([:'vite_rails:set_node_env'])
7
- end
8
-
9
- # Ensure dependencies are installed in older versions of Rails
10
- Rake::Task['assets:precompile']&.enhance([:'vite:install_dependencies']) if installation_tasks.none?
11
-
12
3
  require 'vite_ruby'
13
4
  ViteRuby.install_tasks
14
-
15
- namespace :vite_rails do
16
- desc 'Fixes Rails management of node dev dependencies (build dependencies)'
17
- task :set_node_env do
18
- ENV['NODE_ENV'] = 'development'
19
- end
20
- end
@@ -25,6 +25,15 @@ module ViteRailsLegacy::Installation
25
25
  inject_line_before layout_file, '</head>', <<-HTML
26
26
  <%= vite_client_tag %>
27
27
  <%= vite_javascript_tag 'application' %>
28
+ <!--
29
+ If using a TypeScript entrypoint file:
30
+ vite_typescript_tag 'application'
31
+
32
+ If using a .jsx or .tsx entrypoint, add the extension:
33
+ vite_javascript_tag 'application.jsx'
34
+
35
+ Visit the guide for more information: https://vite-ruby.netlify.app/guide/rails
36
+ -->
28
37
  HTML
29
38
  end
30
39
  end
@@ -9,6 +9,11 @@ module ViteRailsLegacy::TagHelpers
9
9
  "<script#{ tag_options({ src: src, type: 'module' }, escape: true) }></script>".html_safe
10
10
  end
11
11
 
12
+ # Public: Renders a script tag to enable HMR with React Refresh.
13
+ def vite_react_refresh_tag
14
+ vite_manifest.react_refresh_preamble&.html_safe
15
+ end
16
+
12
17
  # Public: Resolves the path for the specified Vite asset.
13
18
  #
14
19
  # Example:
@@ -24,11 +29,12 @@ module ViteRailsLegacy::TagHelpers
24
29
  skip_preload_tags: false,
25
30
  skip_style_tags: false,
26
31
  crossorigin: 'anonymous',
32
+ media: 'screen',
27
33
  **options)
28
34
  entries = vite_manifest.resolve_entries(*names, type: asset_type)
29
35
  tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
30
- tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin) unless skip_preload_tags
31
- tags << stylesheet_link_tag(*entries.fetch(:stylesheets)) unless skip_style_tags
36
+ tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin, **options) unless skip_preload_tags
37
+ tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, crossorigin: crossorigin, **options) unless skip_style_tags
32
38
  tags
33
39
  end
34
40
 
@@ -51,11 +57,11 @@ private
51
57
  end
52
58
 
53
59
  # Internal: Renders a modulepreload link tag.
54
- def vite_preload_tag(*sources, crossorigin:)
60
+ def vite_preload_tag(*sources, crossorigin:, **options)
55
61
  sources.map { |source|
56
62
  href = path_to_asset(source)
57
63
  try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }))
58
- tag('link', rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin)
64
+ tag('link', rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin, **options)
59
65
  }.join("\n").html_safe
60
66
  end
61
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViteRailsLegacy
4
- VERSION = '2.0.4'
4
+ VERSION = '2.0.9'
5
5
  end
@@ -5,6 +5,14 @@
5
5
  // <%= vite_javascript_tag 'application' %>
6
6
  console.log('Vite ⚡️ Rails')
7
7
 
8
+ // If using a TypeScript entrypoint file:
9
+ // <%= vite_typescript_tag 'application.jsx' %>
10
+ //
11
+ // If you want to use .jsx or .tsx, add the extension:
12
+ // <%= vite_javascript_tag 'application.jsx' %>
13
+
14
+ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
15
+
8
16
  // Example: Load Rails libraries in Vite.
9
17
  //
10
18
  // import '@rails/ujs'
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: 2.0.4
4
+ version: 2.0.9
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: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -61,8 +61,8 @@ 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@2.0.4/vite_rails_legacy
65
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails_legacy@2.0.4/vite_rails_legacy/CHANGELOG.md
64
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails_legacy@2.0.9/vite_rails_legacy
65
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails_legacy@2.0.9/vite_rails_legacy/CHANGELOG.md
66
66
  post_install_message:
67
67
  rdoc_options: []
68
68
  require_paths: