vite_ruby 1.2.0 → 1.2.5

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: d9655dc4d615097239f9382298b8e2080b0ea63b9d23423cbb6c603817b6a3a1
4
- data.tar.gz: 7046d45ec63fdcdb7e712113d0d6861a6c6df11ed06e0befac721315cb31546c
3
+ metadata.gz: 4cf73b3471127a2ca30bb94a9db5eadde2674289194dbe605ae01c3dc9bee817
4
+ data.tar.gz: 93312a90a04807cb3f683f9435fddd399ffdfeda7dff31b9316c9977fb1b7a22
5
5
  SHA512:
6
- metadata.gz: c7553b547d6a411ec608128285c84321a96707906b29c8e5c94f91d8a63db65a8054cb6d529bbaf1f30acc1bbbe98df392ea1bea8f0c80b8c827e6a630e4ab38
7
- data.tar.gz: 4c9b45b1804d5d8aa10cc8997bbe4ab4277d9d2de44c497e679c9d67bb65dcae516210a8b3813ed84aa4627d28656112a40c69878e7f89aab0b6df045cf496f2
6
+ metadata.gz: 789ff6d9d918b741f1430e802ea7fed4404ae3e216748d26b48f48c6a3d41976197f00a7e2ed3878b88d819fb2b812bef14099f753d884e02c6f0ea8acc5b315
7
+ data.tar.gz: 58044eba7336765db7a63bfa871f0c7ede9b28ef8ebf66708eb9c8c669abb7ca24f9855878af55fe02afd3e5d5126e1f49e5ef7e4feeaf8229984f59445c38d1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ ## [1.2.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.4...vite_ruby@1.2.5) (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
+ ## [1.2.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.3...vite_ruby@1.2.4) (2021-04-21)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Avoid removing `base` from proxied requests to avoid confusion. ([25f79a9](https://github.com/ElMassimo/vite_ruby/commit/25f79a9848df3e6c2ffbeb9bd4fbc44f73e4c68a))
16
+
17
+
18
+
19
+ ## [1.2.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.2...vite_ruby@1.2.3) (2021-04-15)
20
+
21
+
22
+ ### Features
23
+
24
+ * Add support for .scss, .less, and .styl entrypoints (close [#50](https://github.com/ElMassimo/vite_ruby/issues/50)) ([bb1d295](https://github.com/ElMassimo/vite_ruby/commit/bb1d2953b3a8c5862d26cdfcd5edc5cc918d1c5a))
25
+
26
+
27
+
28
+ ## [1.2.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.1...vite_ruby@1.2.2) (2021-03-20)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * Avoid prompts when using npx outside a CI ([ed7ccd7](https://github.com/ElMassimo/vite_ruby/commit/ed7ccd7d32c079ab78555ecd36dcb68ad2da331e))
34
+ * Simplify installation of build dependencies by using package manager flags ([5c8bb62](https://github.com/ElMassimo/vite_ruby/commit/5c8bb625926f2ab1788a3e3a22aeafd7104984cb))
35
+
36
+
37
+
38
+ ## [1.2.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.0...vite_ruby@1.2.1) (2021-03-19)
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * Use the mode option in `clobber` ([add76b2](https://github.com/ElMassimo/vite_ruby/commit/add76b2a63ea64336235536b8b5670bace357b6e))
44
+
45
+
46
+
1
47
  # [1.2.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.1.2...vite_ruby@1.2.0) (2021-03-19)
2
48
 
3
49
 
data/lib/tasks/vite.rake CHANGED
@@ -29,9 +29,9 @@ namespace :vite do
29
29
  ViteRuby.commands.verify_install
30
30
  end
31
31
 
32
- desc 'Install all JavaScript dependencies'
32
+ desc 'Ensures build dependencies like Vite are installed when compiling assets'
33
33
  task :install_dependencies do
34
- system({ 'NODE_ENV' => 'development' }, 'npx ci')
34
+ system({ 'NODE_ENV' => 'development' }, 'npx --yes ci')
35
35
  end
36
36
 
37
37
  desc "Provide information on ViteRuby's environment"
@@ -48,3 +48,9 @@ if Rake::Task.task_defined?('assets:precompile')
48
48
  else
49
49
  Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build'])
50
50
  end
51
+
52
+ # Any prerequisite task that installs packages should also install build dependencies.
53
+ if ARGV.include?('assets:precompile')
54
+ ENV['NPM_CONFIG_PRODUCTION'] = 'false'
55
+ ENV['YARN_PRODUCTION'] = 'false'
56
+ end
@@ -7,7 +7,8 @@ class ViteRuby::CLI::Clobber < Dry::CLI::Command
7
7
 
8
8
  option(:mode, default: current_env, values: %w[development production test], aliases: ['m'], desc: 'The mode to use')
9
9
 
10
- def call(**)
10
+ def call(mode:, **)
11
+ ViteRuby.env['VITE_RUBY_MODE'] = mode
11
12
  ViteRuby.commands.clobber
12
13
  end
13
14
  end
@@ -75,7 +75,7 @@ private
75
75
  write(package_json, '{}') unless package_json.exist?
76
76
  Dir.chdir(root) do
77
77
  deps = "vite@#{ ViteRuby::DEFAULT_VITE_VERSION } vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }"
78
- stdout, stderr, status = Open3.capture3({ 'CI' => 'true' }, "npx --package @antfu/ni -- ni -D #{ deps }")
78
+ stdout, stderr, status = Open3.capture3({}, "npx --yes --package @antfu/ni -- ni -D #{ deps }")
79
79
  stdout, stderr, = Open3.capture3({}, "yarn add -D #{ deps }") unless status.success?
80
80
  say(stdout, "\n", stderr)
81
81
  end
@@ -31,9 +31,9 @@ private
31
31
 
32
32
  def rewrite_uri_for_vite(env)
33
33
  uri = env.fetch('REQUEST_URI') { [env['PATH_INFO'], env['QUERY_STRING']].reject { |str| str.to_s.strip.empty? }.join('?') }
34
- .sub(vite_asset_url_prefix, '/')
35
34
  .sub(HOST_WITH_PORT_REGEX, '/') # Hanami adds the host and port.
36
35
  .sub('.ts.js', '.ts') # Hanami's javascript helper always adds the extension.
36
+ .sub(/(\.\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
37
37
  env['PATH_INFO'], env['QUERY_STRING'] = (env['REQUEST_URI'] = uri).split('?')
38
38
  end
39
39
 
@@ -46,6 +46,21 @@ class ViteRuby::Manifest
46
46
  prefix_vite_asset('@vite/client') if dev_server_running?
47
47
  end
48
48
 
49
+ # Public: The content of the preamble needed by the React Refresh plugin.
50
+ def react_refresh_preamble
51
+ if dev_server_running?
52
+ <<~REACT_REFRESH
53
+ <script type="module">
54
+ import RefreshRuntime from '#{ prefix_vite_asset('@react-refresh') }'
55
+ RefreshRuntime.injectIntoGlobalHook(window)
56
+ window.$RefreshReg$ = () => {}
57
+ window.$RefreshSig$ = () => (type) => type
58
+ window.__vite_plugin_react_preamble_installed__ = true
59
+ </script>
60
+ REACT_REFRESH
61
+ end
62
+ end
63
+
49
64
  protected
50
65
 
51
66
  # Internal: Strict version of lookup.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-19 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: dry-cli
@@ -237,8 +237,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
237
237
  licenses:
238
238
  - MIT
239
239
  metadata:
240
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.0/vite_ruby
241
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.0/vite_ruby/CHANGELOG.md
240
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.5/vite_ruby
241
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.5/vite_ruby/CHANGELOG.md
242
242
  post_install_message:
243
243
  rdoc_options: []
244
244
  require_paths: