vite_rails 2.0.7 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20bd6ede6dd8f9d7dc2e7962b342220423c3a4cfef19bd783e130242ce278a28
4
- data.tar.gz: 3e10c7d8344cce3efbc176de6f194d8dd6a9def29b3cd449c0ee9b31daa1babe
3
+ metadata.gz: e2c44cc28668a8e61804ef2480f063517f6867ef609380f625f5cd3ff9acc098
4
+ data.tar.gz: da6a1d70b91bc28e6d97255b8e28e81739d7a5c4cf9d7d9bbdafdbf8d038f0e8
5
5
  SHA512:
6
- metadata.gz: bd548a60a845cf787d82f6f5a36c7fd97da0d195a09d64167273daea564abeacedd4448befee0bbbbb1029a5a24228a4a92605ca8e926ee57d9824a1b3e9c69f
7
- data.tar.gz: 3ccd0a17a7c8993439b4879cd6ca499cf1a7fbfec841a227facb1d882a965e7e22346766955209ba39415a35c4ef96a67c7bfc01b3c747e4c2d3836be8cd21e3
6
+ metadata.gz: 121240efd1fae220ac24a3caca2170095ffa39a3dd4684b9920136a13341e6af2fcb49d5295e8fe5113f6a38bade36ed5ede62a1b06d124a19836f21a54f6c7d
7
+ data.tar.gz: c6c51711be2dafa0ff0245438d1ba8c401cbf10c377d21284d863c45aa6e2a72198cb5487c1643c636a97e9ac25234d48465ff04f62e20fa79a2989ebdb82ea0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## [2.0.12](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.11...vite_rails@2.0.12) (2021-05-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fix typo in comment in example entrypoint in Rails ([78b3104](https://github.com/ElMassimo/vite_ruby/commit/78b3104bc687a79aebd4e0538b8b7c34562cb4eb))
7
+
8
+
9
+
10
+ ## [2.0.11](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.10...vite_rails@2.0.11) (2021-05-10)
11
+
12
+
13
+
14
+ ## [2.0.10](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.9...vite_rails@2.0.10) (2021-04-21)
15
+
16
+
17
+ ### Features
18
+
19
+ * Add helpers to enable HMR when using @vitejs/plugin-react-refresh ([a80f286](https://github.com/ElMassimo/vite_ruby/commit/a80f286d4305bbae29ea7cea42a4329a530f43fa))
20
+
21
+
22
+
23
+ ## [2.0.9](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.8...vite_rails@2.0.9) (2021-04-15)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * Allow passing additional attributes to scripts and stylesheets. ([edf6019](https://github.com/ElMassimo/vite_ruby/commit/edf6019fa83646e413f36d289eac89bb2f8042a5))
29
+
30
+
31
+
32
+ ## [2.0.8](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.7...vite_rails@2.0.8) (2021-03-20)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * Simplify installation of build dependencies by using package manager flags ([5c8bb62](https://github.com/ElMassimo/vite_ruby/commit/5c8bb625926f2ab1788a3e3a22aeafd7104984cb))
38
+
39
+
40
+
1
41
  ## [2.0.7](https://github.com/ElMassimo/vite_ruby/compare/vite_rails@2.0.6...vite_rails@2.0.7) (2021-03-19)
2
42
 
3
43
 
data/README.md CHANGED
@@ -43,8 +43,8 @@
43
43
  [heroku]: https://pingcrm-vite.herokuapp.com/
44
44
  [Issues]: https://github.com/ElMassimo/vite_ruby/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
45
45
  [Discussions]: https://github.com/ElMassimo/vite_ruby/discussions
46
- [no bundling]: https://vitejs.dev/guide/introduction.html#the-problem
47
- [bundling]: https://vitejs.dev/guide/introduction.html#why-bundle-for-production
46
+ [no bundling]: https://vitejs.dev/guide/why.html#the-problems
47
+ [bundling]: https://vitejs.dev/guide/why.html#why-bundle-for-production
48
48
 
49
49
  [Vite] is to frontend tooling as Ruby to programming, pure joy! 😍
50
50
 
data/lib/tasks/vite.rake CHANGED
@@ -2,16 +2,3 @@
2
2
 
3
3
  require 'vite_ruby'
4
4
  ViteRuby.install_tasks
5
-
6
- namespace :vite_rails do
7
- desc 'Fixes Rails management of node dev dependencies (build dependencies)'
8
- task :set_node_env do
9
- ENV['NODE_ENV'] = 'development'
10
- end
11
- end
12
-
13
- # Set NODE_ENV before installation, so that Rails installs JS build dependencies
14
- # on servers that precompile assets.
15
- ['yarn:install', 'webpacker:yarn_install'].each do |name|
16
- Rake::Task[name].enhance([:'vite_rails:set_node_env']) if Rake::Task.task_defined?(name)
17
- end
@@ -11,7 +11,7 @@ module ViteRails::Installation
11
11
  def setup_app_files
12
12
  cp RAILS_TEMPLATES.join('config/rails-vite.json'), config.config_path
13
13
  if dir = %w[app/javascript app/packs].find { |path| root.join(path).exist? }
14
- Dry::CLI::Utils::Files.replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "#{ dir }",)
14
+ replace_first_line config.config_path, 'app/frontend', %( "sourceCodeDir": "#{ dir }",)
15
15
  end
16
16
  setup_content_security_policy root.join('config/initializers/content_security_policy.rb')
17
17
  end
@@ -9,6 +9,11 @@ module ViteRails::TagHelpers
9
9
  tag.script(src: src, type: 'module')
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 ViteRails::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 ViteRails
4
- VERSION = '2.0.7'
4
+ VERSION = '2.0.12'
5
5
  end
@@ -6,7 +6,7 @@
6
6
  console.log('Vite ⚡️ Rails')
7
7
 
8
8
  // If using a TypeScript entrypoint file:
9
- // <%= vite_typescript_tag 'application.jsx' %>
9
+ // <%= vite_typescript_tag 'application' %>
10
10
  //
11
11
  // If you want to use .jsx or .tsx, add the extension:
12
12
  // <%= vite_javascript_tag 'application.jsx' %>
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: 2.0.7
4
+ version: 2.0.12
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-19 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -81,8 +81,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
81
81
  licenses:
82
82
  - MIT
83
83
  metadata:
84
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@2.0.7/vite_rails
85
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@2.0.7/vite_rails/CHANGELOG.md
84
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@2.0.12/vite_rails
85
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@2.0.12/vite_rails/CHANGELOG.md
86
86
  post_install_message:
87
87
  rdoc_options: []
88
88
  require_paths: