vite_rails 3.0.2 → 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: ede7e994b9efc576479fa558cef2b7394becd3da260caec53765e692e0df1301
4
- data.tar.gz: 3a999d199170c26c1e8a7764f125209cf3ead26231a14117c517f8b090c42b43
3
+ metadata.gz: b468faa93a51c963d70a987a45f6dbb605c3854dd9ec188d40f0a93c085508d5
4
+ data.tar.gz: a04b6b5f89227b70c1d82e3a649ee1b6d423beedc1e1408126528962ba2962a0
5
5
  SHA512:
6
- metadata.gz: 867c4c13da0539166d095dc3cf7bbb52a6d154bbcedf06b93a6136cf40192323d1d6cd1d528b5144a39e6bd363efa33045a650c9d48ad7a9192f2aad1b533f93
7
- data.tar.gz: a93704d6f78a297d00285e9f4b56bd8f6694486a0e451de88fefb44a9fed11c385b74a5b0639ad6d2c1c18e5bebd06eb874745a912b1b1031209ffaf14f1ce4c
6
+ metadata.gz: 5d5d14601db1a186747566549bd620c1d6c534fe111a2dd9712694743ae3ba691200c56628f1a9fd08c0edbbce68da81ecd28d7e338b8fac215f2bf4b1c99373
7
+ data.tar.gz: 305be4fa2c036e0b8ef509b38fb50985f7c3a8ff8caedc608b919b436a048ffe1d06c5a136a0183ebd80faf5946882ae0a76814eac809e017477c22f7bcbbe24
data/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ # [](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.5...vite_rails@) (2022-01-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **experimental:** add support for Subresource Integrity via vite-plugin-manifest-sri ([0b3142c](https://github.com/ElMassimo/vite_ruby/commit/0b3142cd9d569a5f56821f53cdade337779bb0c1))
7
+
8
+
9
+
10
+ ## [3.0.5](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.4...vite_rails@3.0.5) (2022-01-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * update example setup from turbolinks to @hotwired/turbo ([e1750bf](https://github.com/ElMassimo/vite_ruby/commit/e1750bfb4b22a9a73a2b86950fb203d3e489ced6))
16
+
17
+
18
+
19
+ ## [3.0.4](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.3...vite_rails@3.0.4) (2022-01-02)
20
+
21
+
22
+ ### Features
23
+
24
+ * add style-src to suggestion Content Security Policy changes ([#169](https://github.com/ElMassimo/vite_ruby/issues/169)) ([ec7f4f7](https://github.com/ElMassimo/vite_ruby/commit/ec7f4f7a030a852115b38748dd3cdb22ec3b7e47))
25
+
26
+
27
+
28
+ ## [3.0.3](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.2...vite_rails@3.0.3) (2021-12-22)
29
+
30
+
31
+
1
32
  ## [3.0.2](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@3.0.1...vite_rails@3.0.2) (2021-12-12)
2
33
 
3
34
 
@@ -30,9 +30,13 @@ module ViteRails::Installation
30
30
  # policy.connect_src *policy.connect_src, "ws://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
31
31
  CSP
32
32
  inject_line_after csp_file, 'policy.script_src', <<~CSP
33
- # Allow @vite/client to hot reload changes in development
33
+ # Allow @vite/client to hot reload javascript changes in development
34
34
  # policy.script_src *policy.script_src, :unsafe_eval, "http://\#{ ViteRuby.config.host_with_port }" if Rails.env.development?
35
35
  CSP
36
+ inject_line_after csp_file, 'policy.style_src', <<~CSP
37
+ # Allow @vite/client to hot reload style changes in development
38
+ # policy.style_src *policy.style_src, :unsafe_inline if Rails.env.development?
39
+ CSP
36
40
  end
37
41
 
38
42
  # Override: Create a sample JS file and attempt to inject it in an HTML template.
@@ -26,15 +26,27 @@ module ViteRails::TagHelpers
26
26
  def vite_javascript_tag(*names,
27
27
  type: 'module',
28
28
  asset_type: :javascript,
29
+ integrity: false,
29
30
  skip_preload_tags: false,
30
31
  skip_style_tags: false,
31
32
  crossorigin: 'anonymous',
32
33
  media: 'screen',
33
34
  **options)
34
35
  entries = vite_manifest.resolve_entries(*names, type: asset_type)
35
- tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, extname: false, **options)
36
- 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
41
+
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
47
+
37
48
  tags << stylesheet_link_tag(*entries.fetch(:stylesheets), media: media, crossorigin: crossorigin, **options) unless skip_style_tags
49
+
38
50
  tags
39
51
  end
40
52
 
@@ -44,9 +56,23 @@ module ViteRails::TagHelpers
44
56
  end
45
57
 
46
58
  # Public: Renders a <link> tag for the specified Vite entrypoints.
47
- def vite_stylesheet_tag(*names, **options)
48
- style_paths = names.map { |name| vite_asset_path(name, type: :stylesheet) }
49
- 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
65
+ end
66
+
67
+ # Public: Renders an <img> tag for the specified Vite asset.
68
+ def vite_image_tag(name, **options)
69
+ if options[:srcset] && !options[:srcset].is_a?(String)
70
+ options[:srcset] = options[:srcset].map do |src_name, size|
71
+ "#{ vite_asset_path(src_name) } #{ size }"
72
+ end.join(', ')
73
+ end
74
+
75
+ image_tag(vite_asset_path(name), options)
50
76
  end
51
77
 
52
78
  private
@@ -57,11 +83,13 @@ private
57
83
  end
58
84
 
59
85
  # Internal: Renders a modulepreload link tag.
60
- def vite_preload_tag(*sources, crossorigin:, **options)
61
- sources.map { |source|
62
- href = path_to_asset(source)
63
- try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }))
64
- tag.link(rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin, **options)
65
- }.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)
66
94
  end
67
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViteRails
4
- VERSION = '3.0.2'
4
+ VERSION = '4.0.0.alpha1'
5
5
  end
@@ -15,16 +15,14 @@ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify
15
15
 
16
16
  // Example: Load Rails libraries in Vite.
17
17
  //
18
- // import '@rails/ujs'
18
+ // import * as Turbo from '@hotwired/turbo'
19
+ // Turbo.start()
19
20
  //
20
- // import Turbolinks from 'turbolinks'
21
21
  // import ActiveStorage from '@rails/activestorage'
22
+ // ActiveStorage.start()
22
23
  //
23
24
  // // Import all channels.
24
25
  // const channels = import.meta.globEager('./**/*_channel.js')
25
- //
26
- // Turbolinks.start()
27
- // ActiveStorage.start()
28
26
 
29
27
  // Example: Import a stylesheet in app/frontend/index.css
30
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.2
4
+ version: 4.0.0.alpha1
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-12-12 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '3.0'
39
+ version: 4.0.0.alpha1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '3.0'
46
+ version: 4.0.0.alpha1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: spring
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -82,8 +82,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
82
82
  licenses:
83
83
  - MIT
84
84
  metadata:
85
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@3.0.2/vite_rails
86
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@3.0.2/vite_rails/CHANGELOG.md
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
87
  post_install_message:
88
88
  rdoc_options: []
89
89
  require_paths:
@@ -95,11 +95,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
95
  version: '2.5'
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ">="
98
+ - - ">"
99
99
  - !ruby/object:Gem::Version
100
- version: '0'
100
+ version: 1.3.1
101
101
  requirements: []
102
- rubygems_version: 3.1.4
102
+ rubygems_version: 3.2.32
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Use Vite in Rails and bring joy to your JavaScript experience