vite_ruby 1.2.15 → 1.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/vite_ruby.rb +23 -26
- data/lib/vite_ruby/builder.rb +2 -2
- data/lib/vite_ruby/cli/install.rb +1 -1
- data/lib/vite_ruby/dev_server_proxy.rb +9 -5
- data/lib/vite_ruby/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c040d1223758720987dc50a487c8cb2cbf07dba6b9bfb5a8a56b883931615d8
|
4
|
+
data.tar.gz: a6d9fcf29261cab2f4411830378e7b9658264450ff45feb736db5858cd8db7be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13b6146ffcea5681a48c377bdabc798016c95ec595448274eb7deb1d64296244969f47c0f8cd4a5da9cde158dfaca746b07e4dee60feb153809b2b420e62fa6a
|
7
|
+
data.tar.gz: 684bf03f8e55ff25def1f3d051a3e2111644bc1b080a1faa2a2dbc0c85a925a771a2a6979e7068d9b35736fa155703ef0f851cb56e477999897e9bd3fd8c8697
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## <small>1.2.18 (2021-07-19)</small>
|
2
|
+
|
3
|
+
* chore: Avoid inline regex in dev server proxy ([77728aa](https://github.com/ElMassimo/vite_ruby/commit/77728aa))
|
4
|
+
* test: Update after experimental proxy changes ([1d2e3c7](https://github.com/ElMassimo/vite_ruby/commit/1d2e3c7))
|
5
|
+
* release: vite_ruby@1.2.18-rc1 ([be92933](https://github.com/ElMassimo/vite_ruby/commit/be92933))
|
6
|
+
* 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)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## [1.2.17](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.16...vite_ruby@1.2.17) (2021-07-12)
|
11
|
+
|
12
|
+
* 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)
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
## [1.2.16](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.15...vite_ruby@1.2.16) (2021-07-07)
|
17
|
+
|
18
|
+
* feat: Enable usage in engines by using `run` from the current instance ([023a61d](https://github.com/ElMassimo/vite_ruby/commit/023a61d))
|
19
|
+
|
20
|
+
|
21
|
+
|
1
22
|
## [1.2.15](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.14...vite_ruby@1.2.15) (2021-07-01)
|
2
23
|
|
3
24
|
|
data/lib/vite_ruby.rb
CHANGED
@@ -35,19 +35,11 @@ class ViteRuby
|
|
35
35
|
class << self
|
36
36
|
extend Forwardable
|
37
37
|
|
38
|
-
def_delegators :instance, :config, :commands, :run_proxy?
|
38
|
+
def_delegators :instance, :config, :commands, :env, :run, :run_proxy?
|
39
39
|
def_delegators :config, :mode
|
40
40
|
|
41
41
|
def instance
|
42
|
-
@instance ||=
|
43
|
-
end
|
44
|
-
|
45
|
-
# Public: Additional environment variables to pass to Vite.
|
46
|
-
#
|
47
|
-
# Example:
|
48
|
-
# ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
49
|
-
def env
|
50
|
-
@env ||= load_env_variables
|
42
|
+
@instance ||= new
|
51
43
|
end
|
52
44
|
|
53
45
|
# Internal: Refreshes the manifest.
|
@@ -60,21 +52,9 @@ class ViteRuby
|
|
60
52
|
load File.expand_path('tasks/vite.rake', __dir__)
|
61
53
|
end
|
62
54
|
|
63
|
-
# Internal:
|
64
|
-
def
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
# Internal: Refreshes the config after setting the env vars.
|
69
|
-
def reload_with(env_vars)
|
70
|
-
env.update(env_vars)
|
71
|
-
@instance = nil
|
72
|
-
config
|
73
|
-
end
|
74
|
-
|
75
|
-
# Internal: Allows to obtain any env variables for configuration options.
|
76
|
-
def load_env_variables
|
77
|
-
ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
55
|
+
# Internal: Creates a new instance with the specified options.
|
56
|
+
def reload_with(**config_options)
|
57
|
+
@instance = new(**config_options)
|
78
58
|
end
|
79
59
|
|
80
60
|
# Internal: Detects if the application has installed a framework-specific
|
@@ -90,6 +70,10 @@ class ViteRuby
|
|
90
70
|
|
91
71
|
attr_writer :logger
|
92
72
|
|
73
|
+
def initialize(**config_options)
|
74
|
+
@config_options = config_options
|
75
|
+
end
|
76
|
+
|
93
77
|
def logger
|
94
78
|
@logger ||= Logger.new($stdout)
|
95
79
|
end
|
@@ -107,6 +91,14 @@ class ViteRuby
|
|
107
91
|
@running_at = false
|
108
92
|
end
|
109
93
|
|
94
|
+
# Public: Additional environment variables to pass to Vite.
|
95
|
+
#
|
96
|
+
# Example:
|
97
|
+
# ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
98
|
+
def env
|
99
|
+
@env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
100
|
+
end
|
101
|
+
|
110
102
|
# Public: The proxy for assets should only run in development mode.
|
111
103
|
def run_proxy?
|
112
104
|
config.mode == 'development'
|
@@ -115,6 +107,11 @@ class ViteRuby
|
|
115
107
|
false
|
116
108
|
end
|
117
109
|
|
110
|
+
# Internal: Executes the vite binary.
|
111
|
+
def run(argv, **options)
|
112
|
+
(@runner ||= ViteRuby::Runner.new(self)).run(argv, **options)
|
113
|
+
end
|
114
|
+
|
118
115
|
# Public: Keeps track of watched files and triggers builds as needed.
|
119
116
|
def builder
|
120
117
|
@builder ||= ViteRuby::Builder.new(self)
|
@@ -127,7 +124,7 @@ class ViteRuby
|
|
127
124
|
|
128
125
|
# Public: Current instance configuration for Vite.
|
129
126
|
def config
|
130
|
-
@config ||= ViteRuby::Config.resolve_config
|
127
|
+
@config ||= ViteRuby::Config.resolve_config(**@config_options)
|
131
128
|
end
|
132
129
|
|
133
130
|
# Public: Enables looking up assets managed by Vite using name and type.
|
data/lib/vite_ruby/builder.rb
CHANGED
@@ -33,7 +33,7 @@ private
|
|
33
33
|
|
34
34
|
extend Forwardable
|
35
35
|
|
36
|
-
def_delegators :@vite_ruby, :config, :logger
|
36
|
+
def_delegators :@vite_ruby, :config, :logger, :run
|
37
37
|
|
38
38
|
# Internal: Reads metadata recorded on the last build, if it exists.
|
39
39
|
def last_build_attrs
|
@@ -69,7 +69,7 @@ private
|
|
69
69
|
def build_with_vite(*args)
|
70
70
|
logger.info 'Building with Vite ⚡️'
|
71
71
|
|
72
|
-
stdout, stderr, status =
|
72
|
+
stdout, stderr, status = run(['build', *args])
|
73
73
|
log_build_result(stdout, stderr.to_s, status)
|
74
74
|
|
75
75
|
status.success?
|
@@ -72,7 +72,7 @@ private
|
|
72
72
|
def create_configuration_files
|
73
73
|
copy_template 'config/vite.config.ts', to: root.join('vite.config.ts')
|
74
74
|
setup_app_files
|
75
|
-
ViteRuby.reload_with(
|
75
|
+
ViteRuby.reload_with(config_path: config.config_path)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Internal: Installs vite and vite-plugin-ruby at the project level.
|
@@ -33,7 +33,7 @@ private
|
|
33
33
|
uri = env.fetch('REQUEST_URI') { [env['PATH_INFO'], env['QUERY_STRING']].reject { |str| str.to_s.strip.empty? }.join('?') }
|
34
34
|
.sub(HOST_WITH_PORT_REGEX, '/') # Hanami adds the host and port.
|
35
35
|
.sub('.ts.js', '.ts') # Hanami's javascript helper always adds the extension.
|
36
|
-
.sub(/(\.(?!min)\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
|
36
|
+
.sub(/(\.(?!min|module)\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
|
|
@@ -49,12 +49,16 @@ private
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def vite_should_handle?(env)
|
52
|
-
path
|
52
|
+
path = env['PATH_INFO']
|
53
53
|
return true if path.start_with?(vite_asset_url_prefix) # Vite asset
|
54
54
|
return true if path.start_with?(VITE_DEPENDENCY_PREFIX) # Packages and imports
|
55
|
-
return true if
|
56
|
-
|
57
|
-
|
55
|
+
return true if vite_entrypoint?(path) # HMR for entrypoint stylesheets and imports does not include the prefix
|
56
|
+
end
|
57
|
+
|
58
|
+
# Internal: We want to avoid checking the filesystem if possible
|
59
|
+
def vite_entrypoint?(path)
|
60
|
+
path.include?('.') &&
|
61
|
+
config.resolved_entrypoints_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
|
58
62
|
end
|
59
63
|
|
60
64
|
def vite_asset_url_prefix
|
data/lib/vite_ruby/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.18
|
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-
|
11
|
+
date: 2021-07-19 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.
|
202
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.
|
201
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.18/vite_ruby
|
202
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.18/vite_ruby/CHANGELOG.md
|
203
203
|
post_install_message:
|
204
204
|
rdoc_options: []
|
205
205
|
require_paths:
|