vite_rails 1.0.12 → 2.0.0
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 +6 -0
- data/README.md +39 -34
- data/lib/tasks/vite.rake +17 -0
- data/lib/vite_rails.rb +5 -82
- data/lib/vite_rails/config.rb +11 -135
- data/lib/vite_rails/engine.rb +7 -11
- data/lib/vite_rails/installation.rb +47 -0
- data/lib/vite_rails/tag_helpers.rb +61 -0
- data/lib/vite_rails/version.rb +2 -2
- data/{test/mounted_app/test/dummy/config/vite.json → templates/config/rails-vite.json} +1 -0
- data/{lib/install/javascript → templates}/entrypoints/application.js +0 -0
- metadata +25 -129
- data/lib/install/bin/vite +0 -17
- data/lib/install/binstubs.rb +0 -6
- data/lib/install/config/vite.config.ts +0 -8
- data/lib/install/config/vite.json +0 -14
- data/lib/install/template.rb +0 -40
- data/lib/tasks/vite/binstubs.rake +0 -12
- data/lib/tasks/vite/build.rake +0 -39
- data/lib/tasks/vite/clean.rake +0 -23
- data/lib/tasks/vite/clobber.rake +0 -20
- data/lib/tasks/vite/info.rake +0 -20
- data/lib/tasks/vite/install.rake +0 -12
- data/lib/tasks/vite/install_dependencies.rake +0 -14
- data/lib/tasks/vite/verify_install.rake +0 -23
- data/lib/vite_rails/builder.rb +0 -111
- data/lib/vite_rails/commands.rb +0 -109
- data/lib/vite_rails/dev_server.rb +0 -23
- data/lib/vite_rails/dev_server_proxy.rb +0 -57
- data/lib/vite_rails/helper.rb +0 -71
- data/lib/vite_rails/manifest.rb +0 -143
- data/lib/vite_rails/runner.rb +0 -53
- data/package.json +0 -19
- data/package/default.vite.json +0 -16
- data/test/builder_test.rb +0 -77
- data/test/commands_test.rb +0 -67
- data/test/config_test.rb +0 -133
- data/test/dev_server_proxy_test.rb +0 -102
- data/test/dev_server_test.rb +0 -9
- data/test/engine_rake_tasks_test.rb +0 -81
- data/test/helper_test.rb +0 -75
- data/test/manifest_test.rb +0 -85
- data/test/mode_test.rb +0 -16
- data/test/mounted_app/Rakefile +0 -6
- data/test/mounted_app/test/dummy/Rakefile +0 -5
- data/test/mounted_app/test/dummy/bin/rails +0 -5
- data/test/mounted_app/test/dummy/bin/rake +0 -5
- data/test/mounted_app/test/dummy/config.ru +0 -7
- data/test/mounted_app/test/dummy/config/application.rb +0 -12
- data/test/mounted_app/test/dummy/config/environment.rb +0 -5
- data/test/mounted_app/test/dummy/package.json +0 -8
- data/test/mounted_app/test/dummy/yarn.lock +0 -208
- data/test/rake_tasks_test.rb +0 -60
- data/test/runner_test.rb +0 -31
- data/test/test_app/Rakefile +0 -5
- data/test/test_app/app/frontend/entrypoints/application.js +0 -2
- data/test/test_app/bin/vite +0 -17
- data/test/test_app/config.ru +0 -7
- data/test/test_app/config/application.rb +0 -13
- data/test/test_app/config/environment.rb +0 -6
- data/test/test_app/config/vite.json +0 -18
- data/test/test_app/config/vite_additional_paths.json +0 -5
- data/test/test_app/config/vite_public_dir.json +0 -5
- data/test/test_app/package.json +0 -13
- data/test/test_app/public/vite-production/manifest-assets.json +0 -10
- data/test/test_app/public/vite-production/manifest.json +0 -39
- data/test/test_app/some.config.js +0 -0
- data/test/test_app/yarn.lock +0 -11
- data/test/test_helper.rb +0 -68
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Public: Allows to render HTML tags for scripts and styles processed by Vite.
|
4
|
+
module ViteRails::TagHelpers
|
5
|
+
# Public: Renders a script tag for vite/client to enable HMR in development.
|
6
|
+
def vite_client_tag
|
7
|
+
return unless src = vite_manifest.vite_client_src
|
8
|
+
|
9
|
+
tag.script(src: src, type: 'module')
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Resolves the path for the specified Vite asset.
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
# <%= vite_asset_path 'calendar.css' %> # => "/vite/assets/calendar-1016838bab065ae1e122.css"
|
16
|
+
def vite_asset_path(name, **options)
|
17
|
+
path_to_asset vite_manifest.path_for(name, **options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Renders a <script> tag for the specified Vite entrypoints.
|
21
|
+
def vite_javascript_tag(*names,
|
22
|
+
type: 'module',
|
23
|
+
asset_type: :javascript,
|
24
|
+
skip_preload_tags: false,
|
25
|
+
skip_style_tags: false,
|
26
|
+
crossorigin: 'anonymous',
|
27
|
+
**options)
|
28
|
+
entries = vite_manifest.resolve_entries(*names, type: asset_type)
|
29
|
+
tags = javascript_include_tag(*entries.fetch(:scripts), crossorigin: crossorigin, type: type, **options)
|
30
|
+
tags << vite_preload_tag(*entries.fetch(:imports), crossorigin: crossorigin) unless skip_preload_tags
|
31
|
+
tags << stylesheet_link_tag(*entries.fetch(:stylesheets)) unless skip_style_tags
|
32
|
+
tags
|
33
|
+
end
|
34
|
+
|
35
|
+
# Public: Renders a <script> tag for the specified Vite entrypoints.
|
36
|
+
def vite_typescript_tag(*names, **options)
|
37
|
+
vite_javascript_tag(*names, asset_type: :typescript, extname: false, **options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Public: Renders a <link> tag for the specified Vite entrypoints.
|
41
|
+
def vite_stylesheet_tag(*names, **options)
|
42
|
+
style_paths = names.map { |name| vite_asset_path(name, type: :stylesheet) }
|
43
|
+
stylesheet_link_tag(*style_paths, **options)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Internal: Returns the current manifest loaded by Vite Ruby.
|
49
|
+
def vite_manifest
|
50
|
+
ViteRuby.instance.manifest
|
51
|
+
end
|
52
|
+
|
53
|
+
# Internal: Renders a modulepreload link tag.
|
54
|
+
def vite_preload_tag(*sources, crossorigin:)
|
55
|
+
sources.map { |source|
|
56
|
+
href = path_to_asset(source)
|
57
|
+
try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }))
|
58
|
+
tag.link(rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin)
|
59
|
+
}.join("\n").html_safe
|
60
|
+
end
|
61
|
+
end
|
data/lib/vite_rails/version.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,41 +25,41 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: vite_ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: 1.3.0
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -67,33 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop-minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.93.1
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.93.1
|
82
|
+
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rubocop-performance
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,75 +105,21 @@ files:
|
|
119
105
|
- CONTRIBUTING.md
|
120
106
|
- LICENSE.txt
|
121
107
|
- README.md
|
122
|
-
- lib/
|
123
|
-
- lib/install/binstubs.rb
|
124
|
-
- lib/install/config/vite.config.ts
|
125
|
-
- lib/install/config/vite.json
|
126
|
-
- lib/install/javascript/entrypoints/application.js
|
127
|
-
- lib/install/template.rb
|
128
|
-
- lib/tasks/vite/binstubs.rake
|
129
|
-
- lib/tasks/vite/build.rake
|
130
|
-
- lib/tasks/vite/clean.rake
|
131
|
-
- lib/tasks/vite/clobber.rake
|
132
|
-
- lib/tasks/vite/info.rake
|
133
|
-
- lib/tasks/vite/install.rake
|
134
|
-
- lib/tasks/vite/install_dependencies.rake
|
135
|
-
- lib/tasks/vite/verify_install.rake
|
108
|
+
- lib/tasks/vite.rake
|
136
109
|
- lib/vite_rails.rb
|
137
|
-
- lib/vite_rails/builder.rb
|
138
|
-
- lib/vite_rails/commands.rb
|
139
110
|
- lib/vite_rails/config.rb
|
140
|
-
- lib/vite_rails/dev_server.rb
|
141
|
-
- lib/vite_rails/dev_server_proxy.rb
|
142
111
|
- lib/vite_rails/engine.rb
|
143
|
-
- lib/vite_rails/
|
144
|
-
- lib/vite_rails/
|
145
|
-
- lib/vite_rails/runner.rb
|
112
|
+
- lib/vite_rails/installation.rb
|
113
|
+
- lib/vite_rails/tag_helpers.rb
|
146
114
|
- lib/vite_rails/version.rb
|
147
|
-
-
|
148
|
-
-
|
149
|
-
|
150
|
-
- test/commands_test.rb
|
151
|
-
- test/config_test.rb
|
152
|
-
- test/dev_server_proxy_test.rb
|
153
|
-
- test/dev_server_test.rb
|
154
|
-
- test/engine_rake_tasks_test.rb
|
155
|
-
- test/helper_test.rb
|
156
|
-
- test/manifest_test.rb
|
157
|
-
- test/mode_test.rb
|
158
|
-
- test/mounted_app/Rakefile
|
159
|
-
- test/mounted_app/test/dummy/Rakefile
|
160
|
-
- test/mounted_app/test/dummy/bin/rails
|
161
|
-
- test/mounted_app/test/dummy/bin/rake
|
162
|
-
- test/mounted_app/test/dummy/config.ru
|
163
|
-
- test/mounted_app/test/dummy/config/application.rb
|
164
|
-
- test/mounted_app/test/dummy/config/environment.rb
|
165
|
-
- test/mounted_app/test/dummy/config/vite.json
|
166
|
-
- test/mounted_app/test/dummy/package.json
|
167
|
-
- test/mounted_app/test/dummy/yarn.lock
|
168
|
-
- test/rake_tasks_test.rb
|
169
|
-
- test/runner_test.rb
|
170
|
-
- test/test_app/Rakefile
|
171
|
-
- test/test_app/app/frontend/entrypoints/application.js
|
172
|
-
- test/test_app/bin/vite
|
173
|
-
- test/test_app/config.ru
|
174
|
-
- test/test_app/config/application.rb
|
175
|
-
- test/test_app/config/environment.rb
|
176
|
-
- test/test_app/config/vite.json
|
177
|
-
- test/test_app/config/vite_additional_paths.json
|
178
|
-
- test/test_app/config/vite_public_dir.json
|
179
|
-
- test/test_app/package.json
|
180
|
-
- test/test_app/public/vite-production/manifest-assets.json
|
181
|
-
- test/test_app/public/vite-production/manifest.json
|
182
|
-
- test/test_app/some.config.js
|
183
|
-
- test/test_app/yarn.lock
|
184
|
-
- test/test_helper.rb
|
185
|
-
homepage: https://github.com/ElMassimo/vite_rails
|
115
|
+
- templates/config/rails-vite.json
|
116
|
+
- templates/entrypoints/application.js
|
117
|
+
homepage: https://github.com/ElMassimo/vite_ruby
|
186
118
|
licenses:
|
187
119
|
- MIT
|
188
120
|
metadata:
|
189
|
-
source_code_uri: https://github.com/ElMassimo/
|
190
|
-
changelog_uri: https://github.com/ElMassimo/
|
121
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_rails@2.0.0/vite_rails
|
122
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_rails@2.0.0/vite_rails/CHANGELOG.md
|
191
123
|
post_install_message:
|
192
124
|
rdoc_options: []
|
193
125
|
require_paths:
|
@@ -196,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
128
|
requirements:
|
197
129
|
- - ">="
|
198
130
|
- !ruby/object:Gem::Version
|
199
|
-
version: 2.5
|
131
|
+
version: '2.5'
|
200
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
133
|
requirements:
|
202
134
|
- - ">="
|
@@ -207,40 +139,4 @@ rubygems_version: 3.1.4
|
|
207
139
|
signing_key:
|
208
140
|
specification_version: 4
|
209
141
|
summary: Use Vite in Rails and bring joy to your JavaScript experience
|
210
|
-
test_files:
|
211
|
-
- test/builder_test.rb
|
212
|
-
- test/commands_test.rb
|
213
|
-
- test/config_test.rb
|
214
|
-
- test/dev_server_proxy_test.rb
|
215
|
-
- test/dev_server_test.rb
|
216
|
-
- test/engine_rake_tasks_test.rb
|
217
|
-
- test/helper_test.rb
|
218
|
-
- test/manifest_test.rb
|
219
|
-
- test/mode_test.rb
|
220
|
-
- test/mounted_app/Rakefile
|
221
|
-
- test/mounted_app/test/dummy/Rakefile
|
222
|
-
- test/mounted_app/test/dummy/bin/rails
|
223
|
-
- test/mounted_app/test/dummy/bin/rake
|
224
|
-
- test/mounted_app/test/dummy/config.ru
|
225
|
-
- test/mounted_app/test/dummy/config/application.rb
|
226
|
-
- test/mounted_app/test/dummy/config/environment.rb
|
227
|
-
- test/mounted_app/test/dummy/config/vite.json
|
228
|
-
- test/mounted_app/test/dummy/package.json
|
229
|
-
- test/mounted_app/test/dummy/yarn.lock
|
230
|
-
- test/rake_tasks_test.rb
|
231
|
-
- test/runner_test.rb
|
232
|
-
- test/test_app/Rakefile
|
233
|
-
- test/test_app/app/frontend/entrypoints/application.js
|
234
|
-
- test/test_app/bin/vite
|
235
|
-
- test/test_app/config.ru
|
236
|
-
- test/test_app/config/application.rb
|
237
|
-
- test/test_app/config/environment.rb
|
238
|
-
- test/test_app/config/vite.json
|
239
|
-
- test/test_app/config/vite_additional_paths.json
|
240
|
-
- test/test_app/config/vite_public_dir.json
|
241
|
-
- test/test_app/package.json
|
242
|
-
- test/test_app/public/vite-production/manifest-assets.json
|
243
|
-
- test/test_app/public/vite-production/manifest.json
|
244
|
-
- test/test_app/some.config.js
|
245
|
-
- test/test_app/yarn.lock
|
246
|
-
- test/test_helper.rb
|
142
|
+
test_files: []
|
data/lib/install/bin/vite
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
|
5
|
-
ENV['NODE_ENV'] ||= ENV['RAILS_ENV'] == 'development' ? 'development' : 'production'
|
6
|
-
|
7
|
-
require 'pathname'
|
8
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
9
|
-
|
10
|
-
require 'bundler/setup'
|
11
|
-
|
12
|
-
require 'vite_rails'
|
13
|
-
|
14
|
-
APP_ROOT = File.expand_path('..', __dir__)
|
15
|
-
Dir.chdir(APP_ROOT) do
|
16
|
-
ViteRails.run(ARGV)
|
17
|
-
end
|
data/lib/install/binstubs.rb
DELETED
data/lib/install/template.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Install Vite Rails
|
4
|
-
say 'Creating configuration files'
|
5
|
-
copy_file "#{ __dir__ }/config/vite.json", ViteRails.config.config_path
|
6
|
-
copy_file "#{ __dir__ }/config/vite.config.ts", Rails.root.join('vite.config.ts')
|
7
|
-
|
8
|
-
say 'Creating entrypoints directory'
|
9
|
-
directory "#{ __dir__ }/javascript/entrypoints", ViteRails.config.resolved_entrypoints_dir
|
10
|
-
|
11
|
-
apply "#{ __dir__ }/binstubs.rb"
|
12
|
-
|
13
|
-
git_ignore_path = Rails.root.join('.gitignore')
|
14
|
-
if git_ignore_path.exist?
|
15
|
-
append_to_file(git_ignore_path) {
|
16
|
-
<<~GITIGNORE
|
17
|
-
|
18
|
-
# Vite on Rails
|
19
|
-
/public/vite
|
20
|
-
/public/vite-dev
|
21
|
-
/public/vite-test
|
22
|
-
node_modules
|
23
|
-
*.local
|
24
|
-
.DS_Store
|
25
|
-
GITIGNORE
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
Dir.chdir(Rails.root) do
|
30
|
-
say 'Installing JavaScript dependencies for Vite Rails'
|
31
|
-
package_json = File.read("#{ __dir__ }/../../package.json")
|
32
|
-
|
33
|
-
vite_version = package_json.match(/"vite": "(.*)"/)[1]
|
34
|
-
plugin_version = package_json.match(/"vite-plugin-ruby": "(.*)"/)[1]
|
35
|
-
|
36
|
-
say 'Installing vite as build dependencies'
|
37
|
-
run "yarn add -D vite@#{ vite_version } vite-plugin-ruby@#{ plugin_version }"
|
38
|
-
end
|
39
|
-
|
40
|
-
say 'Vite ⚡️ Rails successfully installed! 🎉', :green
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
binstubs_template_path = File.expand_path('../../install/binstubs.rb', __dir__).freeze
|
4
|
-
bin_path = ENV['BUNDLE_BIN'] || Rails.root.join('bin')
|
5
|
-
|
6
|
-
namespace :vite do
|
7
|
-
desc 'Installs Vite binstubs in this application'
|
8
|
-
task :binstubs do |task|
|
9
|
-
prefix = task.name.split(/#|vite:binstubs/).first
|
10
|
-
exec "#{ RbConfig.ruby } #{ bin_path }/rails #{ prefix }app:template LOCATION=#{ binstubs_template_path }"
|
11
|
-
end
|
12
|
-
end
|
data/lib/tasks/vite/build.rake
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$stdout.sync = true
|
4
|
-
|
5
|
-
def enhance_assets_precompile
|
6
|
-
# Before installing
|
7
|
-
['yarn:install', 'webpacker:yarn_install'].each do |name|
|
8
|
-
Rake::Task[name].enhance([:'vite:set_node_env']) if Rake::Task.task_defined?(name)
|
9
|
-
end
|
10
|
-
|
11
|
-
# After precompiling
|
12
|
-
Rake::Task['assets:precompile'].enhance do |task|
|
13
|
-
prefix = task.name.split(/#|assets:precompile/).first
|
14
|
-
Rake::Task["#{ prefix }vite:build"].invoke
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
namespace :vite do
|
19
|
-
desc 'Fixes Rails management of node dev dependencies (build dependencies)'
|
20
|
-
task :set_node_env do
|
21
|
-
ENV['NODE_ENV'] = 'development'
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Compile JavaScript packs using vite for production with digests'
|
25
|
-
task build: [:'vite:verify_install', :environment] do
|
26
|
-
ViteRails.build_from_rake
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Compile packs after we've compiled all other assets during precompilation
|
31
|
-
skip_vite_precompile = %w[no false n f].include?(ENV['VITE_RUBY_PRECOMPILE'])
|
32
|
-
|
33
|
-
unless skip_vite_precompile
|
34
|
-
if Rake::Task.task_defined?('assets:precompile')
|
35
|
-
enhance_assets_precompile
|
36
|
-
else
|
37
|
-
Rake::Task.define_task('assets:precompile' => [:'vite:install_dependencies', :'vite:build'])
|
38
|
-
end
|
39
|
-
end
|