vite_ruby 3.3.4 → 3.10.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 +4 -4
- data/CHANGELOG.md +176 -0
- data/default.vite.json +2 -1
- data/exe/vite +3 -3
- data/lib/tasks/vite.rake +43 -47
- data/lib/vite_ruby/build.rb +4 -4
- data/lib/vite_ruby/builder.rb +13 -13
- data/lib/vite_ruby/cli/build.rb +6 -6
- data/lib/vite_ruby/cli/clobber.rb +4 -4
- data/lib/vite_ruby/cli/dev.rb +3 -3
- data/lib/vite_ruby/cli/file_utils.rb +16 -9
- data/lib/vite_ruby/cli/install.rb +44 -32
- data/lib/vite_ruby/cli/ssr.rb +8 -8
- data/lib/vite_ruby/cli/upgrade.rb +4 -4
- data/lib/vite_ruby/cli/upgrade_packages.rb +3 -4
- data/lib/vite_ruby/cli/version.rb +1 -1
- data/lib/vite_ruby/cli/vite.rb +20 -9
- data/lib/vite_ruby/cli.rb +13 -13
- data/lib/vite_ruby/commands.rb +20 -74
- data/lib/vite_ruby/compatibility_check.rb +7 -7
- data/lib/vite_ruby/config.rb +54 -38
- data/lib/vite_ruby/dev_server_proxy.rb +21 -20
- data/lib/vite_ruby/error.rb +1 -1
- data/lib/vite_ruby/io.rb +3 -3
- data/lib/vite_ruby/manifest.rb +42 -23
- data/lib/vite_ruby/missing_entrypoint_error.rb +9 -10
- data/lib/vite_ruby/missing_executable_error.rb +1 -1
- data/lib/vite_ruby/runner.rb +16 -14
- data/lib/vite_ruby/version.rb +3 -3
- data/lib/vite_ruby.rb +26 -26
- metadata +36 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52b419f382add7a0b9e770508e0de2b9638ac04f2ac59a1864d34f77e32badd3
|
|
4
|
+
data.tar.gz: 23c8c09217c63a4805a77a06557ea77cad59bf42c0bc0005474c93b9904c3953
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cc569bf315f76cbbad4cf094e3a70497f5e1b650ac50b6e0a065423c87d94f1a612ef9ae7c95bd98ec59177659aaf0e125d3c4dc03f5232897bca7fd981abd2
|
|
7
|
+
data.tar.gz: 7be90c92960550713e350cafbd12e1cc297b0a9006f914a33873db2d23b57f3a75eb10adde901181269fbd17f4db3a2bbbbc1d37517b8e9db1de918ee6735d26
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,179 @@
|
|
|
1
|
+
## [3.10.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.1...vite_ruby@3.10.2) (2026-03-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* ensure imported CSS is resolved recursively (close [#600](https://github.com/ElMassimo/vite_ruby/issues/600)) ([#601](https://github.com/ElMassimo/vite_ruby/issues/601)) ([de4f4a0](https://github.com/ElMassimo/vite_ruby/commit/de4f4a0d0d80990dd73ade74ac40b1e7abdf40b6))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [3.10.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.0...vite_ruby@3.10.1) (2026-03-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* adding `web:` to `Procfile.dev` during installation (close [#599](https://github.com/ElMassimo/vite_ruby/issues/599)) ([5ed99b4](https://github.com/ElMassimo/vite_ruby/commit/5ed99b40b2688ee91c73ee382a2a7a632bcc9bac))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [3.10.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.9.3...vite_ruby@3.10.0) (2026-03-17)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* avoid displaying manifest contents (close [#568](https://github.com/ElMassimo/vite_ruby/issues/568)) ([edc8e13](https://github.com/ElMassimo/vite_ruby/commit/edc8e13d205e27332f8f1339588a7d007a1faa7a))
|
|
25
|
+
* binstub creation ([#589](https://github.com/ElMassimo/vite_ruby/issues/589)) ([cd2ad27](https://github.com/ElMassimo/vite_ruby/commit/cd2ad273ddf155f7c89098d5a25de4d58b31da16))
|
|
26
|
+
* Check if `web` entry already on `Procfile.dev` before appending it ([#542](https://github.com/ElMassimo/vite_ruby/issues/542)) ([4546cf4](https://github.com/ElMassimo/vite_ruby/commit/4546cf48cbef881b4b57deb0fd9e43440e9897f4))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* bump default plugin version ([9d8f3b4](https://github.com/ElMassimo/vite_ruby/commit/9d8f3b42e9020a1b6d91bf7432899bff0697fc5a))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [3.9.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.9.2...vite_ruby@3.9.3) (2026-02-25)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* coerce dev server connect timeout when set via env vars ([0e2801e](https://github.com/ElMassimo/vite_ruby/commit/0e2801e6e9a4da6e534d1b0dbba28f5baadefd4d)), closes [#591](https://github.com/ElMassimo/vite_ruby/issues/591)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* upgrade default vite version to 6.2.6 ([95c247a](https://github.com/ElMassimo/vite_ruby/commit/95c247a66d86f15ad9ce783acf92fef96646091b))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [3.9.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.9.1...vite_ruby@3.9.2) (2025-03-26)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* update `detect_package_manager` to look for new Bun lockfile ([#530](https://github.com/ElMassimo/vite_ruby/issues/530)) ([eca05a3](https://github.com/ElMassimo/vite_ruby/commit/eca05a3021250736776746e4711066a1e00fde68))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [3.9.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.9.0...vite_ruby@3.9.1) (2024-11-21)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Performance Improvements
|
|
62
|
+
|
|
63
|
+
* avoid calling `uniq` on array of hashes ([3e6ad00](https://github.com/ElMassimo/vite_ruby/commit/3e6ad001be6baacdec0597d33bc220d4242521af)), closes [#416](https://github.com/ElMassimo/vite_ruby/issues/416)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# [3.9.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.8.3...vite_ruby@3.9.0) (2024-10-11)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
* enforce vite 5 manifest location ([#432](https://github.com/ElMassimo/vite_ruby/issues/432)) ([ce2df58](https://github.com/ElMassimo/vite_ruby/commit/ce2df5859018b3e305fc1a13443199d268dffca8)), closes [/github.com/ElMassimo/vite_ruby/blob/main/vite_ruby/lib/vite_ruby/builder.rb#L16](https://github.com//github.com/ElMassimo/vite_ruby/blob/main/vite_ruby/lib/vite_ruby/builder.rb/issues/L16)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## [3.8.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.8.2...vite_ruby@3.8.3) (2024-10-11)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Bug Fixes
|
|
80
|
+
|
|
81
|
+
* add `logger` as a runtime dependency rather than default gem ([#502](https://github.com/ElMassimo/vite_ruby/issues/502)) ([6abbccf](https://github.com/ElMassimo/vite_ruby/commit/6abbccf7224f99944c0fe63245f0e84f45fce89f))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## [3.8.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.8.1...vite_ruby@3.8.2) (2024-09-05)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
* bump up expected plugin version ([b8dec4f](https://github.com/ElMassimo/vite_ruby/commit/b8dec4f5b516fe2acc63e980b465987c0c2c9c92)), closes [#493](https://github.com/ElMassimo/vite_ruby/issues/493)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## [3.8.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.8.0...vite_ruby@3.8.1) (2024-09-04)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Bug Fixes
|
|
98
|
+
|
|
99
|
+
* actually run vite inside bun ([#492](https://github.com/ElMassimo/vite_ruby/issues/492)) ([36d3e96](https://github.com/ElMassimo/vite_ruby/commit/36d3e96a6ea9bd9f45881cecb5be78510d6ff017))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# [3.8.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.7.0...vite_ruby@3.8.0) (2024-08-12)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Bug Fixes
|
|
107
|
+
|
|
108
|
+
* remove `vite:clean` rake task as it can potentially break apps ([824b4ef](https://github.com/ElMassimo/vite_ruby/commit/824b4ef8397828423d2ddda117bf27e365954961)), closes [#438](https://github.com/ElMassimo/vite_ruby/issues/438) [#490](https://github.com/ElMassimo/vite_ruby/issues/490) [#404](https://github.com/ElMassimo/vite_ruby/issues/404)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Features
|
|
112
|
+
|
|
113
|
+
* remove `ostruct` dependency (closes [#489](https://github.com/ElMassimo/vite_ruby/issues/489)) ([1dfec47](https://github.com/ElMassimo/vite_ruby/commit/1dfec4759bf2c107433c5f1618d97439f6d5bd01))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# [3.7.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.2...vite_ruby@3.7.0) (2024-07-17)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### Features
|
|
121
|
+
|
|
122
|
+
* add `package_manager` config option, experimental support for bun ([#481](https://github.com/ElMassimo/vite_ruby/issues/481)) ([4426cb1](https://github.com/ElMassimo/vite_ruby/commit/4426cb1007dbb58f4637a4423b1e7d640db96841)), closes [#324](https://github.com/ElMassimo/vite_ruby/issues/324)
|
|
123
|
+
* change default execution to use `npx vite` instead ([#480](https://github.com/ElMassimo/vite_ruby/issues/480)) ([330f61f](https://github.com/ElMassimo/vite_ruby/commit/330f61fedadf1274547a069856125e52002d0065)), closes [#462](https://github.com/ElMassimo/vite_ruby/issues/462)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
## [3.6.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.1...vite_ruby@3.6.2) (2024-07-16)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
## [3.6.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.0...vite_ruby@3.6.1) (2024-07-16)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### Bug Fixes
|
|
135
|
+
|
|
136
|
+
* use ESM by default in new installations ([#479](https://github.com/ElMassimo/vite_ruby/issues/479)) ([cc379ca](https://github.com/ElMassimo/vite_ruby/commit/cc379ca613dd4e5863f8556be62ea623b56cfe0c)), closes [#431](https://github.com/ElMassimo/vite_ruby/issues/431)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
# [3.6.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.5.0...vite_ruby@3.6.0) (2024-06-07)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Features
|
|
144
|
+
|
|
145
|
+
* allow skipping dependency install in assets:precompile ([#451](https://github.com/ElMassimo/vite_ruby/issues/451)) ([5a922b2](https://github.com/ElMassimo/vite_ruby/commit/5a922b2071446e3880b17503474a0c7806eab6a7))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# [3.5.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.4.0...vite_ruby@3.5.0) (2023-11-16)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### Bug Fixes
|
|
153
|
+
|
|
154
|
+
* prevent clean from deleting assets referenced in the manifests ([8a581c1](https://github.com/ElMassimo/vite_ruby/commit/8a581c15ff480049bbb14dab1b5a3497308521b5))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### Features
|
|
158
|
+
|
|
159
|
+
* use vite 5 in new installations ([f063f28](https://github.com/ElMassimo/vite_ruby/commit/f063f283f939d15b3c48c1a9b6efcd589fafbaf1))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# [3.4.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.4...vite_ruby@3.4.0) (2023-11-16)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Bug Fixes
|
|
167
|
+
|
|
168
|
+
* **breaking:** check for any existing manifest path before cleaning ([c450483](https://github.com/ElMassimo/vite_ruby/commit/c4504839e11006d50d6503288469cb3de0c6a9cd))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### Features
|
|
172
|
+
|
|
173
|
+
* add support for vite 5, which changed default manifest path ([818132a](https://github.com/ElMassimo/vite_ruby/commit/818132a07af3f17ba27ae09c44fcd59029064238))
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
1
177
|
## [3.3.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.3...vite_ruby@3.3.4) (2023-06-27)
|
|
2
178
|
|
|
3
179
|
|
data/default.vite.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"publicOutputDir": "vite",
|
|
8
8
|
"configPath": "config/vite.json",
|
|
9
9
|
"devServerConnectTimeout": 0.01,
|
|
10
|
+
"packageManager": null,
|
|
10
11
|
"publicDir": "public",
|
|
11
12
|
"entrypointsDir": "entrypoints",
|
|
12
13
|
"sourceCodeDir": "app/frontend",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"https": null,
|
|
17
18
|
"port": 3036,
|
|
18
19
|
"hideBuildConsoleOutput": false,
|
|
19
|
-
"viteBinPath":
|
|
20
|
+
"viteBinPath": null,
|
|
20
21
|
"watchAdditionalPaths": [],
|
|
21
22
|
"base": "",
|
|
22
23
|
"ssrBuildEnabled": false,
|
data/exe/vite
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
ENV[
|
|
4
|
+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
|
|
5
5
|
|
|
6
|
-
require
|
|
7
|
-
require
|
|
6
|
+
require "bundler/setup"
|
|
7
|
+
require "vite_ruby"
|
|
8
8
|
|
|
9
9
|
cli = ViteRuby::CLI
|
|
10
10
|
cli.require_framework_libraries
|
data/lib/tasks/vite.rake
CHANGED
|
@@ -2,51 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
$stdout.sync = true
|
|
4
4
|
|
|
5
|
-
require
|
|
5
|
+
require "rake"
|
|
6
6
|
|
|
7
7
|
namespace :vite do
|
|
8
8
|
task :binstubs do
|
|
9
9
|
ViteRuby.commands.install_binstubs
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
desc
|
|
13
|
-
task build: :
|
|
12
|
+
desc "Bundle frontend entrypoints using ViteRuby"
|
|
13
|
+
task build: :"vite:verify_install" do
|
|
14
14
|
ViteRuby.commands.build_from_task
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
desc
|
|
18
|
-
task build_ssr: :
|
|
19
|
-
ViteRuby.commands.build_from_task(
|
|
17
|
+
desc "Bundle a Node.js app from the SSR entrypoint using ViteRuby"
|
|
18
|
+
task build_ssr: :"vite:verify_install" do
|
|
19
|
+
ViteRuby.commands.build_from_task("--ssr")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
desc
|
|
23
|
-
task build_all: :
|
|
22
|
+
desc "Bundle entrypoints using Vite Ruby (SSR only if enabled)"
|
|
23
|
+
task build_all: :"vite:verify_install" do
|
|
24
24
|
ViteRuby.commands.build_from_task
|
|
25
|
-
ViteRuby.commands.build_from_task(
|
|
25
|
+
ViteRuby.commands.build_from_task("--ssr") if ViteRuby.config.ssr_build_enabled
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
desc
|
|
29
|
-
task :
|
|
30
|
-
ViteRuby.commands.clean_from_task(args)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
desc 'Remove the build output directory for ViteRuby'
|
|
34
|
-
task clobber: :'vite:verify_install' do
|
|
28
|
+
desc "Remove the build output directory for ViteRuby"
|
|
29
|
+
task clobber: :"vite:verify_install" do
|
|
35
30
|
ViteRuby.commands.clobber
|
|
36
31
|
end
|
|
37
32
|
|
|
38
|
-
desc
|
|
33
|
+
desc "Verify if ViteRuby is properly installed in the app"
|
|
39
34
|
task :verify_install do
|
|
40
35
|
ViteRuby.commands.verify_install
|
|
41
36
|
end
|
|
42
37
|
|
|
43
|
-
desc
|
|
38
|
+
desc "Ensure build dependencies like Vite are installed before bundling"
|
|
44
39
|
task :install_dependencies do
|
|
45
|
-
install_env_args = ENV[
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
install_env_args = (ENV["VITE_RUBY_SKIP_INSTALL_DEV_DEPENDENCIES"] == "true") ? {} : {"NODE_ENV" => "development"}
|
|
41
|
+
|
|
42
|
+
install_cmd = case (pkg = ViteRuby.config.package_manager)
|
|
43
|
+
when "npm" then "npm ci"
|
|
44
|
+
else "#{pkg} install --frozen-lockfile"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
system(install_env_args, install_cmd)
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
desc "Provide information on ViteRuby's environment"
|
|
@@ -55,45 +53,43 @@ namespace :vite do
|
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
|
|
58
|
-
unless ENV[
|
|
59
|
-
if Rake::Task.task_defined?(
|
|
60
|
-
Rake::Task[
|
|
56
|
+
unless ENV["VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION"] == "true"
|
|
57
|
+
if Rake::Task.task_defined?("assets:precompile")
|
|
58
|
+
Rake::Task["assets:precompile"].enhance do |task|
|
|
61
59
|
prefix = task.name.split(/#|assets:precompile/).first
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
unless ENV["VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL"] == "true"
|
|
61
|
+
Rake::Task["#{prefix}vite:install_dependencies"].invoke
|
|
62
|
+
end
|
|
63
|
+
Rake::Task["#{prefix}vite:build_all"].invoke
|
|
64
64
|
end
|
|
65
65
|
else
|
|
66
|
-
desc
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Rake::Task.define_task('assets:clean', [:keep, :age])
|
|
73
|
-
end
|
|
74
|
-
Rake::Task['assets:clean'].enhance do |_, args|
|
|
75
|
-
Rake::Task['vite:clean'].invoke(*args.to_h.values)
|
|
66
|
+
desc "Bundle Vite assets"
|
|
67
|
+
if ENV["VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL"] == "true"
|
|
68
|
+
Rake::Task.define_task("assets:precompile" => "vite:build_all")
|
|
69
|
+
else
|
|
70
|
+
Rake::Task.define_task("assets:precompile" => ["vite:install_dependencies", "vite:build_all"])
|
|
71
|
+
end
|
|
76
72
|
end
|
|
77
73
|
|
|
78
|
-
if Rake::Task.task_defined?(
|
|
79
|
-
Rake::Task[
|
|
80
|
-
Rake::Task[
|
|
74
|
+
if Rake::Task.task_defined?("assets:clobber")
|
|
75
|
+
Rake::Task["assets:clobber"].enhance do
|
|
76
|
+
Rake::Task["vite:clobber"].invoke
|
|
81
77
|
end
|
|
82
78
|
else
|
|
83
|
-
desc
|
|
84
|
-
Rake::Task.define_task(
|
|
79
|
+
desc "Remove compiled assets"
|
|
80
|
+
Rake::Task.define_task("assets:clobber" => "vite:clobber")
|
|
85
81
|
end
|
|
86
82
|
end
|
|
87
83
|
|
|
88
84
|
# Any prerequisite task that installs packages should also install build dependencies.
|
|
89
|
-
if ARGV.include?(
|
|
85
|
+
if ARGV.include?("assets:precompile")
|
|
90
86
|
if ViteRuby.commands.legacy_npm_version?
|
|
91
|
-
ENV[
|
|
87
|
+
ENV["NPM_CONFIG_PRODUCTION"] = "false"
|
|
92
88
|
else
|
|
93
|
-
ENV[
|
|
89
|
+
ENV["NPM_CONFIG_INCLUDE"] = "dev"
|
|
94
90
|
end
|
|
95
91
|
|
|
96
92
|
if ViteRuby.commands.legacy_yarn_version?
|
|
97
|
-
ENV[
|
|
93
|
+
ENV["YARN_PRODUCTION"] = "false"
|
|
98
94
|
end
|
|
99
95
|
end
|
data/lib/vite_ruby/build.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "json"
|
|
4
|
+
require "time"
|
|
5
5
|
|
|
6
6
|
# Internal: Value object with information about the last build.
|
|
7
7
|
ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current_digest, :last_build_path, :errors, keyword_init: true) do
|
|
@@ -28,7 +28,7 @@ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current
|
|
|
28
28
|
|
|
29
29
|
# Internal: To make it evident that there's no last build in error messages.
|
|
30
30
|
def default_metadata
|
|
31
|
-
{
|
|
31
|
+
{timestamp: "never", digest: "none"}
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -56,7 +56,7 @@ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current
|
|
|
56
56
|
def with_result(**attrs)
|
|
57
57
|
self.class.new(
|
|
58
58
|
**attrs,
|
|
59
|
-
timestamp: Time.now.strftime(
|
|
59
|
+
timestamp: Time.now.strftime("%F %T"),
|
|
60
60
|
vite_ruby: ViteRuby::VERSION,
|
|
61
61
|
digest: current_digest,
|
|
62
62
|
current_digest: current_digest,
|
data/lib/vite_ruby/builder.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "digest/sha1"
|
|
4
4
|
|
|
5
5
|
# Public: Keeps track of watched files and triggers builds as needed.
|
|
6
6
|
class ViteRuby::Builder
|
|
@@ -11,18 +11,18 @@ class ViteRuby::Builder
|
|
|
11
11
|
# Public: Checks if the watched files have changed since the last compilation,
|
|
12
12
|
# and triggers a Vite build if any files have changed.
|
|
13
13
|
def build(*args)
|
|
14
|
-
last_build = last_build_metadata(ssr: args.include?(
|
|
14
|
+
last_build = last_build_metadata(ssr: args.include?("--ssr"))
|
|
15
15
|
|
|
16
|
-
if args.delete(
|
|
16
|
+
if args.delete("--force") || last_build.stale? || config.manifest_paths.empty?
|
|
17
17
|
stdout, stderr, status = build_with_vite(*args)
|
|
18
18
|
log_build_result(stdout, stderr, status)
|
|
19
19
|
record_build_metadata(last_build, errors: stderr, success: status.success?)
|
|
20
20
|
status.success?
|
|
21
21
|
elsif last_build.success
|
|
22
|
-
logger.debug "Skipping vite build. Watched files have not changed since the last build at #{
|
|
22
|
+
logger.debug "Skipping vite build. Watched files have not changed since the last build at #{last_build.timestamp}"
|
|
23
23
|
true
|
|
24
24
|
else
|
|
25
|
-
logger.error "Skipping vite build. Watched files have not changed since the build failed at #{
|
|
25
|
+
logger.error "Skipping vite build. Watched files have not changed since the build failed at #{last_build.timestamp} ❌"
|
|
26
26
|
false
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -46,7 +46,7 @@ private
|
|
|
46
46
|
|
|
47
47
|
# Internal: The file path where metadata of the last build is stored.
|
|
48
48
|
def last_build_path(ssr:)
|
|
49
|
-
config.build_cache_dir.join("last#{
|
|
49
|
+
config.build_cache_dir.join("last#{"-ssr" if ssr}-build-#{config.mode}.json")
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# Internal: Returns a digest of all the watched files, allowing to detect
|
|
@@ -56,17 +56,17 @@ private
|
|
|
56
56
|
|
|
57
57
|
config.within_root do
|
|
58
58
|
files = Dir[*config.watched_paths].reject { |f| File.directory?(f) }
|
|
59
|
-
file_ids = files.sort.map { |f| "#{
|
|
59
|
+
file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
|
|
60
60
|
@last_digest_at = Time.now
|
|
61
|
-
@last_digest = Digest::SHA1.hexdigest(file_ids.join(
|
|
61
|
+
@last_digest = Digest::SHA1.hexdigest(file_ids.join("/"))
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# Public: Initiates a Vite build command to generate assets.
|
|
66
66
|
def build_with_vite(*args)
|
|
67
|
-
logger.info
|
|
67
|
+
logger.info "Building with Vite ⚡️"
|
|
68
68
|
|
|
69
|
-
run([
|
|
69
|
+
run(["build", *args])
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# Internal: Outputs the build results.
|
|
@@ -74,13 +74,13 @@ private
|
|
|
74
74
|
# NOTE: By default it also outputs the manifest entries.
|
|
75
75
|
def log_build_result(_stdout, stderr, status)
|
|
76
76
|
if status.success?
|
|
77
|
-
logger.info "Build with Vite complete: #{
|
|
77
|
+
logger.info "Build with Vite complete: #{config.build_output_dir}"
|
|
78
78
|
logger.error stderr unless stderr.empty?
|
|
79
79
|
else
|
|
80
80
|
logger.error stderr
|
|
81
81
|
logger.error status
|
|
82
|
-
logger.error
|
|
83
|
-
logger.error
|
|
82
|
+
logger.error "Build with Vite failed! ❌"
|
|
83
|
+
logger.error "❌ Check that vite and vite-plugin-ruby are in devDependencies and have been installed. " if stderr.include?("ERR! canceled")
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
data/lib/vite_ruby/cli/build.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class ViteRuby::CLI::Build < ViteRuby::CLI::Vite
|
|
4
|
-
DEFAULT_ENV = CURRENT_ENV ||
|
|
4
|
+
DEFAULT_ENV = CURRENT_ENV || "production"
|
|
5
5
|
|
|
6
|
-
desc
|
|
6
|
+
desc "Bundle all entrypoints using Vite."
|
|
7
7
|
shared_options
|
|
8
|
-
option(:ssr, desc:
|
|
9
|
-
option(:force, desc:
|
|
10
|
-
option(:watch, desc:
|
|
11
|
-
option(:profile, desc:
|
|
8
|
+
option(:ssr, desc: "Build the SSR entrypoint instead", type: :boolean)
|
|
9
|
+
option(:force, desc: "Force the build even if assets have not changed", type: :boolean)
|
|
10
|
+
option(:watch, desc: "Start the Rollup watcher and rebuild on files changes", type: :boolean)
|
|
11
|
+
option(:profile, desc: "Gather performance metrics from the build ", type: :boolean)
|
|
12
12
|
|
|
13
13
|
def call(**options)
|
|
14
14
|
super { |args| ViteRuby.commands.build_from_task(*args) }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class ViteRuby::CLI::Clobber < Dry::CLI::Command
|
|
4
|
-
desc
|
|
4
|
+
desc "Clear the Vite cache, temp files, and builds"
|
|
5
5
|
|
|
6
|
-
current_env = ENV[
|
|
6
|
+
current_env = ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development"
|
|
7
7
|
|
|
8
|
-
option(:mode, default: current_env, values: %w[development production test], aliases: [
|
|
8
|
+
option(:mode, default: current_env, values: %w[development production test], aliases: ["m"], desc: "The mode to use")
|
|
9
9
|
|
|
10
10
|
def call(mode:, **)
|
|
11
|
-
ViteRuby.env[
|
|
11
|
+
ViteRuby.env["VITE_RUBY_MODE"] = mode
|
|
12
12
|
ViteRuby.commands.clobber
|
|
13
13
|
end
|
|
14
14
|
end
|
data/lib/vite_ruby/cli/dev.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class ViteRuby::CLI::Dev < ViteRuby::CLI::Vite
|
|
4
|
-
DEFAULT_ENV = CURRENT_ENV ||
|
|
4
|
+
DEFAULT_ENV = CURRENT_ENV || "development"
|
|
5
5
|
|
|
6
|
-
desc
|
|
6
|
+
desc "Start the Vite development server."
|
|
7
7
|
shared_options
|
|
8
|
-
option(:force, desc:
|
|
8
|
+
option(:force, desc: "Force Vite to re-bundle dependencies", type: :boolean)
|
|
9
9
|
|
|
10
10
|
def call(**options)
|
|
11
11
|
super { |args| ViteRuby.run(args, exec: true) }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "pathname"
|
|
4
|
+
require "fileutils"
|
|
5
5
|
|
|
6
6
|
# NOTE: Extracted from dry-cli version 0.6.0, which later removed this file as
|
|
7
7
|
# it was refactored and extracted into the more complete (and complex) dry-files.
|
|
@@ -32,11 +32,18 @@ module ViteRuby::CLI::FileUtils
|
|
|
32
32
|
# @since 1.2.11
|
|
33
33
|
# @api private
|
|
34
34
|
def append(path, contents)
|
|
35
|
+
append_unless_present(path, contents, pattern: contents)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Adds a new line at the bottom of the file, unless any line matches the pattern.
|
|
39
|
+
#
|
|
40
|
+
# @api private
|
|
41
|
+
def append_unless_present(path, contents, pattern:)
|
|
35
42
|
content = read_lines(path)
|
|
36
|
-
return if content.
|
|
43
|
+
return if content.any? { |line| line.include?(pattern) }
|
|
37
44
|
|
|
38
45
|
content << "\n" unless content.last&.end_with?("\n")
|
|
39
|
-
content << "#{
|
|
46
|
+
content << "#{contents}\n"
|
|
40
47
|
|
|
41
48
|
write(path, content)
|
|
42
49
|
end
|
|
@@ -47,7 +54,7 @@ module ViteRuby::CLI::FileUtils
|
|
|
47
54
|
# @api private
|
|
48
55
|
def replace_first_line(path, target, replacement)
|
|
49
56
|
content = read_lines(path)
|
|
50
|
-
content[index(content, path, target)] = "#{
|
|
57
|
+
content[index(content, path, target)] = "#{replacement}\n"
|
|
51
58
|
|
|
52
59
|
write(path, content)
|
|
53
60
|
end
|
|
@@ -95,14 +102,14 @@ module ViteRuby::CLI::FileUtils
|
|
|
95
102
|
# @api private
|
|
96
103
|
def index(content, path, target)
|
|
97
104
|
content.index { |line| line.include?(target) } ||
|
|
98
|
-
raise(ArgumentError, "Cannot find `#{
|
|
105
|
+
raise(ArgumentError, "Cannot find `#{target}' inside `#{path}'.")
|
|
99
106
|
end
|
|
100
107
|
|
|
101
108
|
# @since 1.2.11
|
|
102
109
|
# @api private
|
|
103
110
|
def rindex(content, path, target)
|
|
104
111
|
content.rindex { |line| line.include?(target) } ||
|
|
105
|
-
raise(ArgumentError, "Cannot find `#{
|
|
112
|
+
raise(ArgumentError, "Cannot find `#{target}' inside `#{path}'.")
|
|
106
113
|
end
|
|
107
114
|
|
|
108
115
|
# @since 1.2.11
|
|
@@ -113,7 +120,7 @@ module ViteRuby::CLI::FileUtils
|
|
|
113
120
|
|
|
114
121
|
i = finder.call(content, path, target)
|
|
115
122
|
|
|
116
|
-
content.insert(i, "#{
|
|
123
|
+
content.insert(i, "#{contents}\n")
|
|
117
124
|
write(path, content)
|
|
118
125
|
end
|
|
119
126
|
|
|
@@ -125,7 +132,7 @@ module ViteRuby::CLI::FileUtils
|
|
|
125
132
|
|
|
126
133
|
i = finder.call(content, path, target)
|
|
127
134
|
|
|
128
|
-
content.insert(i + 1, "#{
|
|
135
|
+
content.insert(i + 1, "#{contents}\n")
|
|
129
136
|
write(path, content)
|
|
130
137
|
end
|
|
131
138
|
end
|