vite_ruby 3.6.0 → 4.0.0.alpha1

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: 184968fc31cdfdcafe5fea4b2ba393155ae968df6a7ffb11fd9ff7c6b30da671
4
- data.tar.gz: 1cdbbef05db2234af7496421fad1569d3c3a81d86dd5b88ca8fa27fe19159aaa
3
+ metadata.gz: 3e369fc30038cbf7475208298ccc3eebbcec6ad98100b785d6303b766afc3aad
4
+ data.tar.gz: '0811dc3a900d49b9b0b3c406b32b96e852d5a367dce1c96924b6b0a936fddc39'
5
5
  SHA512:
6
- metadata.gz: 54c6f374fb5254bad6eccadfc21928f7bceb7871fdc9077261f52837203d1c85855519c824f24d9bbbff243bd2f02bd8ec300fd3323451ea09902b7cd12bf63a
7
- data.tar.gz: 31c1ab4e450b3ce0619ebffeda6565868fea3f2b197ffec35a5abddc3101940d6fc856967f568fd2196628a3e2171cfd21313ee4ecbe23ca732f79696da055bc
6
+ metadata.gz: ef190e8c53cf93255f56a69fa7db7fe684f1fc4924b21aca81d9d2160ec117accf643771a5692bf58225884958fa06fc3b1e713241eaa6f2f223b8fca35e216a
7
+ data.tar.gz: 22b63dc5256c147ddf084f0324f2e6a236b86b654e6cd63e99da2608c6869290aa80885b8d9c61f8c7056df449464cb24831717de5e1a0857b5cf28af303700c
data/CHANGELOG.md CHANGED
@@ -1,334 +1,9 @@
1
- # [3.6.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.5.0...vite_ruby@3.6.0) (2024-06-07)
1
+ # [](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.8...vite_ruby@) (2022-01-18)
2
2
 
3
3
 
4
4
  ### Features
5
5
 
6
- * 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))
7
-
8
-
9
-
10
- # [3.5.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.4.0...vite_ruby@3.5.0) (2023-11-16)
11
-
12
-
13
- ### Bug Fixes
14
-
15
- * prevent clean from deleting assets referenced in the manifests ([8a581c1](https://github.com/ElMassimo/vite_ruby/commit/8a581c15ff480049bbb14dab1b5a3497308521b5))
16
-
17
-
18
- ### Features
19
-
20
- * use vite 5 in new installations ([f063f28](https://github.com/ElMassimo/vite_ruby/commit/f063f283f939d15b3c48c1a9b6efcd589fafbaf1))
21
-
22
-
23
-
24
- # [3.4.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.4...vite_ruby@3.4.0) (2023-11-16)
25
-
26
-
27
- ### Bug Fixes
28
-
29
- * **breaking:** check for any existing manifest path before cleaning ([c450483](https://github.com/ElMassimo/vite_ruby/commit/c4504839e11006d50d6503288469cb3de0c6a9cd))
30
-
31
-
32
- ### Features
33
-
34
- * add support for vite 5, which changed default manifest path ([818132a](https://github.com/ElMassimo/vite_ruby/commit/818132a07af3f17ba27ae09c44fcd59029064238))
35
-
36
-
37
-
38
- ## [3.3.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.3...vite_ruby@3.3.4) (2023-06-27)
39
-
40
-
41
- ### Bug Fixes
42
-
43
- * check only once per second when dev server is not running ([#377](https://github.com/ElMassimo/vite_ruby/issues/377)) ([fb33f0a](https://github.com/ElMassimo/vite_ruby/commit/fb33f0a28077f9912deed257b7be3a7e050c2d94))
44
-
45
-
46
-
47
- ## [3.3.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.2...vite_ruby@3.3.3) (2023-06-19)
48
-
49
-
50
- ### Features
51
-
52
- * allow skipping dev dependencies on install ([#374](https://github.com/ElMassimo/vite_ruby/issues/374)) ([a309f4f](https://github.com/ElMassimo/vite_ruby/commit/a309f4f9fc62fb7b9d0728b66b30ad90e68ba7bf))
53
- * Use javascript_tag helper for vite_react_refresh_tag ([#372](https://github.com/ElMassimo/vite_ruby/issues/372)) ([238c6bd](https://github.com/ElMassimo/vite_ruby/commit/238c6bd211c0fafaa6170f0bdd631a0f6e41d992)), closes [#249](https://github.com/ElMassimo/vite_ruby/issues/249)
54
-
55
-
56
-
57
- ## [3.3.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.1...vite_ruby@3.3.2) (2023-05-09)
58
-
59
-
60
- ### Bug Fixes
61
-
62
- * ensure assets:precompile task is displayed when using `rake -T` ([66af6eb](https://github.com/ElMassimo/vite_ruby/commit/66af6eb0268e7a989562feb38da74072817f0d49))
63
-
64
-
65
-
66
- ## [3.3.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.3.0...vite_ruby@3.3.1) (2023-04-28)
67
-
68
-
69
- ### Features
70
-
71
- * upgrade default vite version to 4.3 ([b186456](https://github.com/ElMassimo/vite_ruby/commit/b18645605dd40b312da1137a6440abc8fe4c5ae7))
72
-
73
-
74
-
75
- # [3.3.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.15...vite_ruby@3.3.0) (2023-03-16)
76
-
77
-
78
- ### Features
79
-
80
- * add support for the --profile flag when running vite build ([4a949fd](https://github.com/ElMassimo/vite_ruby/commit/4a949fde1672b899c7c0382e99a669195c7ea639)), closes [#332](https://github.com/ElMassimo/vite_ruby/issues/332)
81
- * change defaults to vite@4.2.0 and vite-plugin-ruby@3.2.0 ([e9f5702](https://github.com/ElMassimo/vite_ruby/commit/e9f570294c34682a6dd18fdc2ef13675f33375e6))
82
-
83
-
84
-
85
- ## [3.2.15](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.14...vite_ruby@3.2.15) (2023-03-01)
86
-
87
-
88
- ### Features
89
-
90
- * install dependencies with yarn if npx is not available ([#343](https://github.com/ElMassimo/vite_ruby/issues/343)) ([90c5db2](https://github.com/ElMassimo/vite_ruby/commit/90c5db2e45ed89aedfa02f0f167925e4ccb02d6d)), closes [#342](https://github.com/ElMassimo/vite_ruby/issues/342)
91
-
92
-
93
-
94
- ## [3.2.14](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.13...vite_ruby@3.2.14) (2022-12-22)
95
-
96
-
97
-
98
- ## [3.2.13](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.12...vite_ruby@3.2.13) (2022-12-09)
99
-
100
-
101
- ### Features
102
-
103
- * install vite 4 by default ([c1a2e16](https://github.com/ElMassimo/vite_ruby/commit/c1a2e16a5b47225c53ad73b4f6371f2108881850))
104
-
105
-
106
-
107
- ## [3.2.12](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.11...vite_ruby@3.2.12) (2022-12-02)
108
-
109
-
110
- ### Features
111
-
112
- * add experimental `skipProxy` setting ([#315](https://github.com/ElMassimo/vite_ruby/issues/315)) ([e9285f6](https://github.com/ElMassimo/vite_ruby/commit/e9285f62c76cc0cbbc5dc99d977e8aef30d08b6f))
113
- * add ViteRuby.instance.configure API to be used in config/vite.rb ([b5b8681](https://github.com/ElMassimo/vite_ruby/commit/b5b8681f85f5388a56d72c9b05dbfc95d5ba607b))
114
-
115
-
116
- ### Performance Improvements
117
-
118
- * avoid calculating digest on each lookup ([#314](https://github.com/ElMassimo/vite_ruby/issues/314)) ([62df93a](https://github.com/ElMassimo/vite_ruby/commit/62df93a15c09c652a8b7496e26cf85d5d69acce7))
119
-
120
-
121
-
122
- ## [3.2.11](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.10...vite_ruby@3.2.11) (2022-11-13)
123
-
124
-
125
- ### Bug Fixes
126
-
127
- * avoid removing double extension for non-preprocessor assets ([#301](https://github.com/ElMassimo/vite_ruby/issues/301)) ([2024f62](https://github.com/ElMassimo/vite_ruby/commit/2024f62af917cabcb817c32a5fbbe709d477c19f))
128
-
129
-
130
-
131
- ## [3.2.10](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.9...vite_ruby@3.2.10) (2022-11-03)
132
-
133
-
134
-
135
- ## [3.2.9](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.8...vite_ruby@3.2.9) (2022-11-02)
136
-
137
-
138
- ### Features
139
-
140
- * allow different ViteRuby instances to set different env vars ([25628a7](https://github.com/ElMassimo/vite_ruby/commit/25628a752cbd4828547c1f454cc4cb2217a591e0))
141
- * output exit code when vite process fails ([#294](https://github.com/ElMassimo/vite_ruby/issues/294)) ([eb8f678](https://github.com/ElMassimo/vite_ruby/commit/eb8f678248a02b693fffe5a49309984fed92a051)), closes [#292](https://github.com/ElMassimo/vite_ruby/issues/292)
142
-
143
-
144
-
145
- ## [3.2.8](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.7...vite_ruby@3.2.8) (2022-10-28)
146
-
147
-
148
- ### Features
149
-
150
- * default to vite@3.2.0 ([2ef83a5](https://github.com/ElMassimo/vite_ruby/commit/2ef83a52148f46534c4106015f3f54ec9ee807cb))
151
-
152
-
153
-
154
- ## [3.2.7](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.6...vite_ruby@3.2.7) (2022-10-19)
155
-
156
-
157
- ### Bug Fixes
158
-
159
- * yarn berry pnp mode support ([#278](https://github.com/ElMassimo/vite_ruby/issues/278)) ([1890447](https://github.com/ElMassimo/vite_ruby/commit/189044746e536847cb33fb471cc7c42251a61072))
160
-
161
-
162
- ### Features
163
-
164
- * create vite-plugin-rails, an opinionated version of `vite-plugin-ruby` ([#282](https://github.com/ElMassimo/vite_ruby/issues/282)) ([16375fb](https://github.com/ElMassimo/vite_ruby/commit/16375fb1f6f2bf86dff935ca3aaf91c333a796ff))
165
-
166
-
167
-
168
- ## [3.2.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.5...vite_ruby@3.2.6) (2022-10-07)
169
-
170
-
171
- ### Features
172
-
173
- * always trigger a build if the manifest is missing ([#275](https://github.com/ElMassimo/vite_ruby/issues/275)) ([53ffdb9](https://github.com/ElMassimo/vite_ruby/commit/53ffdb9559409cb813198b4fd8a7a5ccb0c3cd21))
174
-
175
-
176
-
177
- ## [3.2.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.4...vite_ruby@3.2.5) (2022-10-07)
178
-
179
-
180
- ### Features
181
-
182
- * display last build errors in MissingEntrypointError ([#274](https://github.com/ElMassimo/vite_ruby/issues/274)) ([107c980](https://github.com/ElMassimo/vite_ruby/commit/107c980449546ef73c527b88f1db11a7201e4438))
183
-
184
-
185
-
186
- ## [3.2.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.3...vite_ruby@3.2.4) (2022-10-04)
187
-
188
-
189
- ### Bug Fixes
190
-
191
- * **BREAKING CHANGE:** lookup now returns nil if auto-build fails ([#268](https://github.com/ElMassimo/vite_ruby/issues/268)) ([cf2dec1](https://github.com/ElMassimo/vite_ruby/commit/cf2dec1bfec2279179c1671e5b42479549fd11c4)), closes [#267](https://github.com/ElMassimo/vite_ruby/issues/267)
192
-
193
-
194
-
195
- ## [3.2.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.2...vite_ruby@3.2.3) (2022-08-28)
196
-
197
-
198
- ### Bug Fixes
199
-
200
- * prevent yarn 2+ error in `assets:precompile` ([#241](https://github.com/ElMassimo/vite_ruby/issues/241)) ([e7e857a](https://github.com/ElMassimo/vite_ruby/commit/e7e857ac763dd053a8bda4b27d26a2090269f6d8))
201
-
202
-
203
-
204
- ## [3.2.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.1...vite_ruby@3.2.2) (2022-08-12)
205
-
206
-
207
- ### Features
208
-
209
- * allow framework-specific libraries to extend the CLI ([a0ed66f](https://github.com/ElMassimo/vite_ruby/commit/a0ed66fe64fb2549cecc358ccd60c82be44255aa))
210
-
211
-
212
-
213
- ## [3.2.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.2.0...vite_ruby@3.2.1) (2022-08-11)
214
-
215
-
216
- ### Bug Fixes
217
-
218
- * require the version after defining namespace (close [#239](https://github.com/ElMassimo/vite_ruby/issues/239)) ([7b92062](https://github.com/ElMassimo/vite_ruby/commit/7b920627f0f551166b3ab321e50b6cee746168c2))
219
-
220
-
221
-
222
- # [3.2.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.7...vite_ruby@3.2.0) (2022-07-13)
223
-
224
-
225
- ### Features
226
-
227
- * use Vite 3 as the default ([#225](https://github.com/ElMassimo/vite_ruby/issues/225)) ([8fab191](https://github.com/ElMassimo/vite_ruby/commit/8fab1912dc8c7c600854b490c09a603644714266))
228
-
229
-
230
-
231
- ## [3.1.7](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.6...vite_ruby@3.1.7) (2022-07-13)
232
-
233
-
234
- ### Bug Fixes
235
-
236
- * npm deprecation warning on assets:precompile ([#226](https://github.com/ElMassimo/vite_ruby/issues/226)) ([e4f4b75](https://github.com/ElMassimo/vite_ruby/commit/e4f4b7540ef34296f1a8a4d8f1d2838549ee8460)), closes [#220](https://github.com/ElMassimo/vite_ruby/issues/220)
237
- # [](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.6...vite_ruby@) (2022-07-01)
238
-
239
-
240
- ## [3.1.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.5...vite_ruby@3.1.6) (2022-06-02)
241
-
242
- ### Bug Fixes
243
-
244
- * Catch npm command not found, for folks who install deps with yarn ([7a0407b3211e682bc1da40d29225af58d3396cbd](https://github.com/ElMassimo/vite_ruby/commit/7a0407b3211e682bc1da40d29225af58d3396cbd))
245
-
246
-
247
- ## [3.1.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.4...vite_ruby@3.1.5) (2022-05-30)
248
-
249
-
250
- ### Bug Fixes
251
-
252
- * install dependencies without confirmation in modern versions of npm ([967fbf5](https://github.com/ElMassimo/vite_ruby/commit/967fbf52aac5e52e1a059bffda79c7472874775f)), closes [#216](https://github.com/ElMassimo/vite_ruby/issues/216)
253
-
254
-
255
-
256
- ## [3.1.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.3...vite_ruby@3.1.4) (2022-05-13)
257
-
258
-
259
- ### Features
260
-
261
- * expose `ViteRuby.digest` to simplify asset versioning. ([ff92ce6](https://github.com/ElMassimo/vite_ruby/commit/ff92ce6011d857efa83987d3c20d48767111e700))
262
-
263
-
264
-
265
- ## [3.1.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.2...vite_ruby@3.1.3) (2022-05-13)
266
-
267
-
268
- ### Bug Fixes
269
-
270
- * change default for ssrOutputDir so it's ignored by default ([2f93b76](https://github.com/ElMassimo/vite_ruby/commit/2f93b762b29462cc619527ed47e6fa3cf8d3c8c9))
271
-
272
-
273
-
274
- ## [3.1.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.1...vite_ruby@3.1.2) (2022-05-12)
275
-
276
-
277
- ### Features
278
-
279
- * add support for SSR builds (experimental) ([#212](https://github.com/ElMassimo/vite_ruby/issues/212)) ([4d6cd2b](https://github.com/ElMassimo/vite_ruby/commit/4d6cd2b84f670b1703e3bde7033e822be97bf505))
280
- * ignore any vite dirs in .gitignore installation (for ssr builds) ([fd68420](https://github.com/ElMassimo/vite_ruby/commit/fd68420dfaeb79b97f8edade5bf17bfe81fd2486))
281
-
282
-
283
-
284
- ## [3.1.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.1.0...vite_ruby@3.1.1) (2022-04-14)
285
-
286
-
287
- ### Bug Fixes
288
-
289
- * prevent error when using a proc in asset_host (close [#202](https://github.com/ElMassimo/vite_ruby/issues/202)) ([#203](https://github.com/ElMassimo/vite_ruby/issues/203)) ([cb23a81](https://github.com/ElMassimo/vite_ruby/commit/cb23a81037651ac01d993935f68cc526ec2c844d))
290
-
291
-
292
-
293
- # [3.1.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.11...vite_ruby@3.1.0) (2022-04-01)
294
-
295
-
296
- ### Features
297
-
298
- * improve capistrano-rails integration by extending asset tasks ([#200](https://github.com/ElMassimo/vite_ruby/issues/200)) ([d5704ab](https://github.com/ElMassimo/vite_ruby/commit/d5704ab55abf27cbdb5b00841bce3136147a0200))
299
-
300
-
301
-
302
- ## [3.0.11](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.10...vite_ruby@3.0.11) (2022-04-01)
303
-
304
-
305
- ### Features
306
-
307
- * bump the default vite version ([2cb8952](https://github.com/ElMassimo/vite_ruby/commit/2cb895246b3154322273989057bf9bdc67634bc6))
308
-
309
-
310
-
311
- ## [3.0.10](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.9...vite_ruby@3.0.10) (2022-03-17)
312
-
313
-
314
- ### Bug Fixes
315
-
316
- * avoid proxying requests starting with @ ([93d071b](https://github.com/ElMassimo/vite_ruby/commit/93d071b2b807c2e09e24d5d7ea4228974b370960))
317
- * MissingExecutableError when deploying with Capistrano (close [#192](https://github.com/ElMassimo/vite_ruby/issues/192)) ([22e1691](https://github.com/ElMassimo/vite_ruby/commit/22e1691a0685b1fdeec3904657be5e69a57e6456))
318
-
319
-
320
- ### Features
321
-
322
- * bump up default vite version to 2.8.6 ([fd53030](https://github.com/ElMassimo/vite_ruby/commit/fd5303017760dc176b3fb15908f08a16a175c22f))
323
-
324
-
325
-
326
- ## [3.0.9](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.0.8...vite_ruby@3.0.9) (2022-02-09)
327
-
328
-
329
- ### Bug Fixes
330
-
331
- * support older versions of npm (v6) that ship with node 12 and 14 ([0accc36](https://github.com/ElMassimo/vite_ruby/commit/0accc36e9ef82fa0923af4f94253433433c0b074))
6
+ * **experimental:** add support for Subresource Integrity via vite-plugin-manifest-sri ([0b3142c](https://github.com/ElMassimo/vite_ruby/commit/0b3142cd9d569a5f56821f53cdade337779bb0c1))
332
7
 
333
8
 
334
9
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">
2
2
  <a href="https://vite-ruby.netlify.app/">
3
- <img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/logo.svg" width="120px"/>
3
+ <img src="https://raw.githubusercontent.com/ElMassimo/vite_ruby/main/docs/public/logo.svg" width="120px"/>
4
4
  </a>
5
5
 
6
6
  <br>
data/default.vite.json CHANGED
@@ -11,15 +11,11 @@
11
11
  "entrypointsDir": "entrypoints",
12
12
  "sourceCodeDir": "app/frontend",
13
13
  "skipCompatibilityCheck": false,
14
- "skipProxy": false,
15
14
  "host": "localhost",
16
15
  "https": null,
17
16
  "port": 3036,
18
17
  "hideBuildConsoleOutput": false,
19
18
  "viteBinPath": "node_modules/.bin/vite",
20
19
  "watchAdditionalPaths": [],
21
- "base": "",
22
- "ssrBuildEnabled": false,
23
- "ssrEntrypoint": "~/ssr/ssr.{js,ts,jsx,tsx}",
24
- "ssrOutputDir": "public/vite-ssr"
20
+ "base": ""
25
21
  }
data/exe/vite CHANGED
@@ -7,6 +7,4 @@ require 'bundler/setup'
7
7
  require 'vite_ruby'
8
8
 
9
9
  cli = ViteRuby::CLI
10
- cli.require_framework_libraries
11
-
12
10
  Dry::CLI.new(cli).call
data/lib/tasks/vite.rake CHANGED
@@ -9,44 +9,29 @@ namespace :vite do
9
9
  ViteRuby.commands.install_binstubs
10
10
  end
11
11
 
12
- desc 'Bundle frontend entrypoints using ViteRuby'
12
+ desc 'Compile JavaScript packs using vite for production with digests'
13
13
  task build: :'vite:verify_install' do
14
14
  ViteRuby.commands.build_from_task
15
15
  end
16
16
 
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
- end
21
-
22
- desc 'Bundle entrypoints using Vite Ruby (SSR only if enabled)'
23
- task build_all: :'vite:verify_install' do
24
- ViteRuby.commands.build_from_task
25
- ViteRuby.commands.build_from_task('--ssr') if ViteRuby.config.ssr_build_enabled
26
- end
27
-
28
- desc 'Remove old bundles created by ViteRuby'
17
+ desc 'Remove old compiled vites'
29
18
  task :clean, [:keep, :age] => :'vite:verify_install' do |_, args|
30
19
  ViteRuby.commands.clean_from_task(args)
31
20
  end
32
21
 
33
- desc 'Remove the build output directory for ViteRuby'
22
+ desc 'Remove the vite build output directory'
34
23
  task clobber: :'vite:verify_install' do
35
24
  ViteRuby.commands.clobber
36
25
  end
37
26
 
38
- desc 'Verify if ViteRuby is properly installed in the app'
27
+ desc 'Verifies if ViteRuby is properly installed in this application'
39
28
  task :verify_install do
40
29
  ViteRuby.commands.verify_install
41
30
  end
42
31
 
43
- desc 'Ensure build dependencies like Vite are installed before bundling'
32
+ desc 'Ensures build dependencies like Vite are installed when compiling assets'
44
33
  task :install_dependencies do
45
- install_env_args = ENV['VITE_RUBY_SKIP_INSTALL_DEV_DEPENDENCIES'] == 'true' ? {} : { 'NODE_ENV' => 'development' }
46
- cmd = ViteRuby.commands.legacy_npm_version? ? 'npx ci --yes' : 'npx --yes ci'
47
- result = system(install_env_args, cmd)
48
- # Fallback to `yarn` if `npx` is not available.
49
- system(install_env_args, 'yarn install --frozen-lockfile') if result.nil?
34
+ system({ 'NODE_ENV' => 'development' }, 'npx --yes ci')
50
35
  end
51
36
 
52
37
  desc "Provide information on ViteRuby's environment"
@@ -59,47 +44,15 @@ unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] == 'true'
59
44
  if Rake::Task.task_defined?('assets:precompile')
60
45
  Rake::Task['assets:precompile'].enhance do |task|
61
46
  prefix = task.name.split(/#|assets:precompile/).first
62
- unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
63
- Rake::Task["#{ prefix }vite:install_dependencies"].invoke
64
- end
65
- Rake::Task["#{ prefix }vite:build_all"].invoke
47
+ Rake::Task["#{ prefix }vite:build"].invoke
66
48
  end
67
49
  else
68
- desc 'Bundle Vite assets'
69
- if ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
70
- Rake::Task.define_task('assets:precompile' => 'vite:build_all')
71
- else
72
- Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build_all'])
73
- end
74
- end
75
-
76
- unless Rake::Task.task_defined?('assets:clean')
77
- desc 'Remove old compiled assets'
78
- Rake::Task.define_task('assets:clean', [:keep, :age])
79
- end
80
- Rake::Task['assets:clean'].enhance do |_, args|
81
- Rake::Task['vite:clean'].invoke(*args.to_h.values)
82
- end
83
-
84
- if Rake::Task.task_defined?('assets:clobber')
85
- Rake::Task['assets:clobber'].enhance do
86
- Rake::Task['vite:clobber'].invoke
87
- end
88
- else
89
- desc 'Remove compiled assets'
90
- Rake::Task.define_task('assets:clobber' => 'vite:clobber')
50
+ Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build'])
91
51
  end
92
52
  end
93
53
 
94
54
  # Any prerequisite task that installs packages should also install build dependencies.
95
55
  if ARGV.include?('assets:precompile')
96
- if ViteRuby.commands.legacy_npm_version?
97
- ENV['NPM_CONFIG_PRODUCTION'] = 'false'
98
- else
99
- ENV['NPM_CONFIG_INCLUDE'] = 'dev'
100
- end
101
-
102
- if ViteRuby.commands.legacy_yarn_version?
103
- ENV['YARN_PRODUCTION'] = 'false'
104
- end
56
+ ENV['NPM_CONFIG_PRODUCTION'] = 'false'
57
+ ENV['YARN_PRODUCTION'] = 'false'
105
58
  end
@@ -1,35 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
3
  require 'time'
5
4
 
6
5
  # Internal: Value object with information about the last build.
7
- ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current_digest, :last_build_path, :errors, keyword_init: true) do
8
- class << self
9
- # Internal: Combines information from a previous build with the current digest.
10
- def from_previous(last_build_path, current_digest)
11
- new(
12
- **parse_metadata(last_build_path),
13
- current_digest: current_digest,
14
- last_build_path: last_build_path,
15
- )
16
- end
17
-
18
- private
19
-
20
- # Internal: Reads metadata recorded on the last build, if it exists.
21
- def parse_metadata(pathname)
22
- return default_metadata unless pathname.exist?
23
-
24
- JSON.parse(pathname.read.to_s).transform_keys(&:to_sym).slice(*members)
25
- rescue JSON::JSONError, Errno::ENOENT, Errno::ENOTDIR
26
- default_metadata
27
- end
28
-
29
- # Internal: To make it evident that there's no last build in error messages.
30
- def default_metadata
31
- { timestamp: 'never', digest: 'none' }
32
- end
6
+ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current_digest) do
7
+ # Internal: Combines information from a previous build with the current digest.
8
+ def self.from_previous(attrs, current_digest)
9
+ new(
10
+ attrs['success'],
11
+ attrs['timestamp'] || 'never',
12
+ attrs['vite_ruby'] || 'unknown',
13
+ attrs['digest'] || 'none',
14
+ current_digest,
15
+ )
33
16
  end
34
17
 
35
18
  # Internal: A build is considered stale when watched files have changed since
@@ -53,30 +36,17 @@ ViteRuby::Build = Struct.new(:success, :timestamp, :vite_ruby, :digest, :current
53
36
  end
54
37
 
55
38
  # Internal: Returns a new build with the specified result.
56
- def with_result(**attrs)
39
+ def with_result(success)
57
40
  self.class.new(
58
- **attrs,
59
- timestamp: Time.now.strftime('%F %T'),
60
- vite_ruby: ViteRuby::VERSION,
61
- digest: current_digest,
62
- current_digest: current_digest,
63
- last_build_path: last_build_path,
41
+ success,
42
+ Time.now.strftime('%F %T'),
43
+ ViteRuby::VERSION,
44
+ current_digest,
64
45
  )
65
46
  end
66
47
 
67
- # Internal: Writes the result of the new build to a local file.
68
- def write_to_cache
69
- last_build_path.write to_json
70
- end
71
-
72
48
  # Internal: Returns a JSON string with the metadata of the build.
73
49
  def to_json(*_args)
74
- JSON.pretty_generate(
75
- success: success,
76
- errors: errors,
77
- timestamp: timestamp,
78
- vite_ruby: vite_ruby,
79
- digest: digest,
80
- )
50
+ JSON.pretty_generate(to_h)
81
51
  end
82
52
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
3
4
  require 'digest/sha1'
4
5
 
5
6
  # Public: Keeps track of watched files and triggers builds as needed.
@@ -11,13 +12,9 @@ class ViteRuby::Builder
11
12
  # Public: Checks if the watched files have changed since the last compilation,
12
13
  # and triggers a Vite build if any files have changed.
13
14
  def build(*args)
14
- last_build = last_build_metadata(ssr: args.include?('--ssr'))
15
-
16
- if args.delete('--force') || last_build.stale? || config.manifest_paths.empty?
17
- stdout, stderr, status = build_with_vite(*args)
18
- log_build_result(stdout, stderr, status)
19
- record_build_metadata(last_build, errors: stderr, success: status.success?)
20
- status.success?
15
+ last_build = last_build_metadata
16
+ if args.delete('--force') || last_build.stale?
17
+ build_with_vite(*args).tap { |success| record_build_metadata(success, last_build) }
21
18
  elsif last_build.success
22
19
  logger.debug "Skipping vite build. Watched files have not changed since the last build at #{ last_build.timestamp }"
23
20
  true
@@ -28,8 +25,8 @@ class ViteRuby::Builder
28
25
  end
29
26
 
30
27
  # Internal: Reads the result of the last compilation from disk.
31
- def last_build_metadata(ssr: false)
32
- ViteRuby::Build.from_previous(last_build_path(ssr: ssr), watched_files_digest)
28
+ def last_build_metadata
29
+ ViteRuby::Build.from_previous(last_build_attrs, watched_files_digest)
33
30
  end
34
31
 
35
32
  private
@@ -38,35 +35,44 @@ private
38
35
 
39
36
  def_delegators :@vite_ruby, :config, :logger, :run
40
37
 
38
+ # Internal: Reads metadata recorded on the last build, if it exists.
39
+ def last_build_attrs
40
+ last_build_path.exist? ? JSON.parse(last_build_path.read.to_s) : {}
41
+ rescue JSON::JSONError, Errno::ENOENT, Errno::ENOTDIR
42
+ {}
43
+ end
44
+
41
45
  # Internal: Writes a digest of the watched files to disk for future checks.
42
- def record_build_metadata(build, **attrs)
46
+ def record_build_metadata(success, build)
43
47
  config.build_cache_dir.mkpath
44
- build.with_result(**attrs).write_to_cache
48
+ last_build_path.write build.with_result(success).to_json
45
49
  end
46
50
 
47
51
  # Internal: The file path where metadata of the last build is stored.
48
- def last_build_path(ssr:)
49
- config.build_cache_dir.join("last#{ '-ssr' if ssr }-build-#{ config.mode }.json")
52
+ def last_build_path
53
+ config.build_cache_dir.join("last-build-#{ config.mode }.json")
50
54
  end
51
55
 
52
56
  # Internal: Returns a digest of all the watched files, allowing to detect
53
57
  # changes, and skip Vite builds if no files have changed.
54
58
  def watched_files_digest
55
- return @last_digest if @last_digest_at && Time.now - @last_digest_at < 1
56
-
57
- config.within_root do
59
+ Dir.chdir File.expand_path(config.root) do
58
60
  files = Dir[*config.watched_paths].reject { |f| File.directory?(f) }
59
61
  file_ids = files.sort.map { |f| "#{ File.basename(f) }/#{ Digest::SHA1.file(f).hexdigest }" }
60
- @last_digest_at = Time.now
61
- @last_digest = Digest::SHA1.hexdigest(file_ids.join('/'))
62
+ Digest::SHA1.hexdigest(file_ids.join('/'))
62
63
  end
63
64
  end
64
65
 
65
66
  # Public: Initiates a Vite build command to generate assets.
67
+ #
68
+ # Returns true if the build is successful, or false if it failed.
66
69
  def build_with_vite(*args)
67
70
  logger.info 'Building with Vite ⚡️'
68
71
 
69
- run(['build', *args])
72
+ stdout, stderr, status = run(['build', *args])
73
+ log_build_result(stdout, stderr.to_s, status)
74
+
75
+ status.success?
70
76
  end
71
77
 
72
78
  # Internal: Outputs the build results.
@@ -75,10 +81,9 @@ private
75
81
  def log_build_result(_stdout, stderr, status)
76
82
  if status.success?
77
83
  logger.info "Build with Vite complete: #{ config.build_output_dir }"
78
- logger.error stderr unless stderr.empty?
84
+ logger.error stderr.to_s unless stderr.empty?
79
85
  else
80
86
  logger.error stderr
81
- logger.error status
82
87
  logger.error 'Build with Vite failed! ❌'
83
88
  logger.error '❌ Check that vite and vite-plugin-ruby are in devDependencies and have been installed. ' if stderr.include?('ERR! canceled')
84
89
  end