vite_ruby 1.2.18.pre.rc1 → 2.0.0.beta.2

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: bf73135bcdc5fca1765711184c1c25f6d9605e99659b963f832eada7a14f3000
4
- data.tar.gz: 9d231937d47c050a96be530d99cb80c4568b196f8242f0c52e803cf55f8bfb52
3
+ metadata.gz: 8f6ca7bd5b83588c6e0118597ba98d5477979d10348ae86a757f25942f179286
4
+ data.tar.gz: aa1dd99bd6e495e77ab56376a6b5ae691490c26114d1c707cc6dc14c293e11f4
5
5
  SHA512:
6
- metadata.gz: 92062092819c7df51342d4d3fa9ac345e89c151553e2c7c0a3193a957f53964aef9c84f4dd837abea9b7b805bd65c26a28f0b4a2fc464ff99b75601845263271
7
- data.tar.gz: 1ede81f69afd524fa0f9fe03b944427b92ed93b111bac5a0d0b953dc630e8c9b6a74c85b4e0d1a6119275a9088b79bc38dd35608d79ed5a938f2d9bf2173c3f6
6
+ metadata.gz: 47e230e531f02ff5d1a5f8ed3467d1d15aede112cf3dfad4bd993b4870819969434da21d65a93427428ca5683c5fb4aa5b4f64d0c0dd9f9736752b2291b3990c
7
+ data.tar.gz: 13c81b2beee62dec05099f673585af7cdce73cd96e9191e7083f3e55f50a5ee4d9c15ef4f58938305cc9d74726f4f7d17c301170cb0a2415f74ee4a0a28abd7e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [1.2.20](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.18...vite_ruby@1.2.20) (2021-07-30)
2
+
3
+
4
+ ### Features
5
+
6
+ * use `asset_host` for Vite client if set during development ([89a338c](https://github.com/ElMassimo/vite_ruby/commit/89a338c2f23e6b43af9dadfd937fe29c82a08b10))
7
+ * Watch Windi CSS config file by default if it exists ([842c5eb](https://github.com/ElMassimo/vite_ruby/commit/842c5eb46cd12887f28ed62cb656d81645c7239c))
8
+
9
+
10
+
11
+ ## [1.2.18](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.17...vite_ruby@1.2.18) (2021-07-19)
12
+
13
+ * fix: Proxy entrypoint HMR requests only after verifying the file exists (close #102) ([67c22ec](https://github.com/ElMassimo/vite_ruby/commit/67c22ec)), closes [#102](https://github.com/ElMassimo/vite_ruby/issues/102)
14
+
15
+
1
16
  ## [1.2.17](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.16...vite_ruby@1.2.17) (2021-07-12)
2
17
 
3
18
  * fix: Proxy CSS Modules requests to Vite.js with the correct extension (close #98) ([8976872](https://github.com/ElMassimo/vite_ruby/commit/8976872)), closes [#98](https://github.com/ElMassimo/vite_ruby/issues/98)
data/default.vite.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "additionalInputGlobs": ["{assets,fonts,icons,images}/**/*"],
2
3
  "assetHost": null,
3
4
  "assetsDir": "assets",
4
5
  "autoBuild": false,
data/lib/vite_ruby.rb CHANGED
@@ -18,8 +18,8 @@ class ViteRuby
18
18
  ENV_PREFIX = 'VITE_RUBY'
19
19
 
20
20
  # Internal: Versions used by default when running `vite install`.
21
- DEFAULT_VITE_VERSION = '^2.3.8'
22
- DEFAULT_PLUGIN_VERSION = '^2.0.4'
21
+ DEFAULT_VITE_VERSION = '^2.5.0-beta.2'
22
+ DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.1'
23
23
 
24
24
  # Internal: Companion libraries for Vite Ruby, and their target framework.
25
25
  COMPANION_LIBRARIES = {
@@ -102,6 +102,7 @@ private
102
102
  'package.json',
103
103
  'vite.config.ts',
104
104
  'vite.config.js',
105
+ 'windi.config.ts',
105
106
  config.config_path,
106
107
  ].freeze
107
108
  end
@@ -138,7 +138,7 @@ private
138
138
  DEFAULT_CONFIG = load_json("#{ __dir__ }/../../default.vite.json").freeze
139
139
 
140
140
  # Internal: Configuration options that can not be provided as env vars.
141
- NOT_CONFIGURABLE_WITH_ENV = %w[watch_additional_paths].freeze
141
+ NOT_CONFIGURABLE_WITH_ENV = %w[additional_input_globs watch_additional_paths].freeze
142
142
 
143
143
  # Internal: Configuration options that can be provided as env vars.
144
144
  CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root] - NOT_CONFIGURABLE_WITH_ENV).freeze
@@ -58,7 +58,7 @@ private
58
58
  # Internal: We want to avoid checking the filesystem if possible
59
59
  def vite_entrypoint?(path)
60
60
  path.include?('.') &&
61
- config.resolved_entrypoints_dir.join(path.delete_prefix('/')).file?
61
+ config.resolved_entrypoints_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
62
62
  end
63
63
 
64
64
  def vite_asset_url_prefix
@@ -43,7 +43,7 @@ class ViteRuby::Manifest
43
43
 
44
44
  # Public: The path from where the browser can download the Vite HMR client.
45
45
  def vite_client_src
46
- prefix_vite_asset('@vite/client') if dev_server_running?
46
+ prefix_asset_with_host('@vite/client') if dev_server_running?
47
47
  end
48
48
 
49
49
  # Public: The content of the preamble needed by the React Refresh plugin.
@@ -51,7 +51,7 @@ class ViteRuby::Manifest
51
51
  if dev_server_running?
52
52
  <<~REACT_REFRESH
53
53
  <script type="module">
54
- import RefreshRuntime from '#{ prefix_vite_asset('@react-refresh') }'
54
+ import RefreshRuntime from '#{ prefix_asset_with_host('@react-refresh') }'
55
55
  RefreshRuntime.injectIntoGlobalHook(window)
56
56
  window.$RefreshReg$ = () => {}
57
57
  window.$RefreshSig$ = () => (type) => type
@@ -66,8 +66,8 @@ protected
66
66
  # Internal: Strict version of lookup.
67
67
  #
68
68
  # Returns a relative path for the asset, or raises an error if not found.
69
- def lookup!(*args, **options)
70
- lookup(*args, **options) || missing_entry_error(*args, **options)
69
+ def lookup!(name, **options)
70
+ lookup(name, **options) || missing_entry_error(name, **options)
71
71
  end
72
72
 
73
73
  # Internal: Computes the path for a given Vite asset using manifest.json.
@@ -77,10 +77,10 @@ protected
77
77
  # Example:
78
78
  # manifest.lookup('calendar.js')
79
79
  # => { "file" => "/vite/assets/calendar-1016838bab065ae1e122.js", "imports" => [] }
80
- def lookup(name, type: nil)
80
+ def lookup(name, **options)
81
81
  @build_mutex.synchronize { builder.build } if should_build?
82
82
 
83
- find_manifest_entry(with_file_extension(name, type))
83
+ find_manifest_entry resolve_entry_name(name, **options)
84
84
  end
85
85
 
86
86
  private
@@ -98,9 +98,9 @@ private
98
98
  # Internal: Finds the specified entry in the manifest.
99
99
  def find_manifest_entry(name)
100
100
  if dev_server_running?
101
- { 'file' => prefix_vite_asset(name.to_s) }
101
+ { 'file' => prefix_vite_asset(name) }
102
102
  else
103
- manifest[name.to_s]
103
+ manifest[name]
104
104
  end
105
105
  end
106
106
 
@@ -125,6 +125,12 @@ private
125
125
  File.join("/#{ config.public_output_dir }", path)
126
126
  end
127
127
 
128
+ # Internal: Prefixes an asset with the `asset_host` for tags that do not use
129
+ # the framework tag helpers.
130
+ def prefix_asset_with_host(path)
131
+ File.join(config.asset_host || '/', config.public_output_dir, path)
132
+ end
133
+
128
134
  # Internal: Resolves the paths that reference a manifest entry.
129
135
  def resolve_references(manifest)
130
136
  manifest.each_value do |entry|
@@ -134,12 +140,26 @@ private
134
140
  end
135
141
  end
136
142
 
143
+ # Internal: Resolves the manifest entry name for the specified resource.
144
+ def resolve_entry_name(name, type: nil)
145
+ name = with_file_extension(name.to_s, type)
146
+ name = name[1..-1] if name.start_with?('/')
147
+
148
+ # Prefix scripts and stylesheets with the entrypoints dir.
149
+ if (type || File.dirname(name) == '.') && !name.start_with?(config.entrypoints_dir)
150
+ File.join(config.entrypoints_dir, name)
151
+ else
152
+ name
153
+ end
154
+ end
155
+
137
156
  # Internal: Adds a file extension to the file name, unless it already has one.
138
157
  def with_file_extension(name, entry_type)
139
- return name unless File.extname(name.to_s).empty?
140
-
141
- extension = extension_for_type(entry_type)
142
- extension ? "#{ name }.#{ extension }" : name
158
+ if File.extname(name).empty? && (ext = extension_for_type(entry_type))
159
+ "#{ name }.#{ ext }"
160
+ else
161
+ name
162
+ end
143
163
  end
144
164
 
145
165
  # Internal: Allows to receive :javascript and :stylesheet as :type in helpers.
@@ -153,9 +173,9 @@ private
153
173
  end
154
174
 
155
175
  # Internal: Raises a detailed message when an entry is missing in the manifest.
156
- def missing_entry_error(name, type: nil, **_options)
176
+ def missing_entry_error(name, **options)
157
177
  raise ViteRuby::MissingEntrypointError, OpenStruct.new(
158
- file_name: with_file_extension(name, type),
178
+ file_name: resolve_entry_name(name, **options),
159
179
  last_build: builder.last_build_metadata,
160
180
  manifest: @manifest,
161
181
  config: config,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '1.2.18-rc1'
4
+ VERSION = '2.0.0.beta.2'
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.18.pre.rc1
4
+ version: 2.0.0.beta.2
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-07-16 00:00:00.000000000 Z
11
+ date: 2021-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -198,8 +198,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
198
198
  licenses:
199
199
  - MIT
200
200
  metadata:
201
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.18-rc1/vite_ruby
202
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.18-rc1/vite_ruby/CHANGELOG.md
201
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@2.0.0.beta.2/vite_ruby
202
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@2.0.0.beta.2/vite_ruby/CHANGELOG.md
203
203
  post_install_message:
204
204
  rdoc_options: []
205
205
  require_paths: