vite_rails 1.0.6 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/CONTRIBUTING.md +0 -1
- data/README.md +43 -70
- data/lib/install/config/vite.config.ts +1 -1
- data/lib/install/javascript/entrypoints/application.js +8 -4
- data/lib/install/template.rb +3 -3
- data/lib/tasks/vite/build.rake +12 -6
- data/lib/tasks/vite/clean.rake +1 -3
- data/lib/tasks/vite/install_dependencies.rake +3 -9
- data/lib/tasks/vite/verify_install.rake +3 -3
- data/lib/vite_rails.rb +23 -34
- data/lib/vite_rails/builder.rb +11 -13
- data/lib/vite_rails/commands.rb +51 -10
- data/lib/vite_rails/config.rb +65 -35
- data/lib/vite_rails/dev_server_proxy.rb +26 -18
- data/lib/vite_rails/helper.rb +17 -8
- data/lib/vite_rails/manifest.rb +14 -12
- data/lib/vite_rails/runner.rb +3 -6
- data/lib/vite_rails/version.rb +1 -1
- data/package.json +9 -2
- data/package/default.vite.json +2 -1
- data/test/builder_test.rb +27 -22
- data/test/commands_test.rb +67 -0
- data/test/config_test.rb +133 -0
- data/test/dev_server_proxy_test.rb +102 -0
- data/test/dev_server_test.rb +0 -30
- data/test/engine_rake_tasks_test.rb +56 -17
- data/test/helper_test.rb +37 -105
- data/test/manifest_test.rb +33 -29
- data/test/mode_test.rb +6 -11
- data/test/mounted_app/test/dummy/config/vite.json +5 -11
- data/test/mounted_app/test/dummy/package.json +5 -4
- data/test/mounted_app/test/dummy/yarn.lock +208 -0
- data/test/rake_tasks_test.rb +7 -21
- data/test/runner_test.rb +31 -0
- data/test/test_app/app/frontend/entrypoints/application.js +2 -0
- data/test/test_app/config/vite.json +0 -2
- data/test/test_app/config/vite_additional_paths.json +5 -0
- data/test/test_app/config/vite_public_dir.json +5 -0
- data/test/test_app/public/vite-production/manifest.json +22 -0
- data/test/test_helper.rb +48 -14
- metadata +23 -25
- data/test/command_test.rb +0 -35
- data/test/configuration_test.rb +0 -80
- data/test/dev_server_runner_test.rb +0 -83
- data/test/test_app/app/javascript/entrypoints/application.js +0 -10
- data/test/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
- data/test/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
- data/test/test_app/config/vite_public_root.yml +0 -20
- data/test/test_app/public/vite/manifest.json +0 -36
- data/test/vite_runner_test.rb +0 -59
- data/test/webpacker_test.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c6ae06bd2fe02d39882813646c291aa1984bf6f4bfbd337859c8527f83cdd66
|
4
|
+
data.tar.gz: 932af2eeadf8830685a6f1d30431849b1e46227147f34a11b286824d3ce80cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f388f8c74bd39ee14f9d8033941a7616400f9e725a1c2cec7f459f9faa06457dcb113648d9bdb672b5497093f3905bddc13928b834c91f43cef08a58de0e65
|
7
|
+
data.tar.gz: fba446503a41accc9bd4a769042858789615b2095171d6c138c0f2aaf0471ce741da98d9aa058fabc1ee92e2f667b8c19bcab48980ea4288d4b4400b53d94f15
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## Vite Rails 1.0.11 (2020-01-24)
|
2
|
+
|
3
|
+
- Fix bug in `assetHost` that caused `base` to be configured incorrectly.
|
4
|
+
- Allow installing `vite` and `vite-plugin-ruby` as devDependencies, and install them when precompiling assets.
|
5
|
+
- Move `base` to the configuration root after Vite's update in beta.38
|
6
|
+
|
7
|
+
## Vite Rails 1.0.10 (2020-01-23)
|
8
|
+
|
9
|
+
- Use `path_to_asset` in `vite_asset_path` so that it's prefixed automatically
|
10
|
+
when using a CDN (`config.action_controller.asset_host`).
|
11
|
+
|
12
|
+
## Vite Rails 1.0.9 (2020-01-22)
|
13
|
+
|
14
|
+
- Ensure `configPath` and `publicDir` are scoped from `root`, both in Ruby and JS.
|
15
|
+
|
16
|
+
## Vite Rails 1.0.8 (2020-01-21)
|
17
|
+
|
18
|
+
- Change the default of `sourceCodeDir` to `app/frontend`, add instructions for folks migrating
|
19
|
+
from a `app/javascript` structure.
|
20
|
+
|
21
|
+
## Vite Rails 1.0.7 (2020-01-20)
|
22
|
+
|
23
|
+
- Add `vite_client_tag` to ensure the Vite client can be loaded in apps that don't use any imports.
|
24
|
+
|
1
25
|
## Vite Rails 1.0.6 (2020-01-20)
|
2
26
|
|
3
27
|
- Ensure running `bin/rake assets:precompile` automatically invokes `vite:build`.
|
data/CONTRIBUTING.md
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
<h1 align="center">
|
2
|
-
|
2
|
+
<a href="https://vite-rails.netlify.app/">
|
3
|
+
<img src="https://raw.githubusercontent.com/ElMassimo/vite_rails/main/docs/public/logo.svg" width="120px"/>
|
4
|
+
</a>
|
5
|
+
|
6
|
+
<br>
|
7
|
+
|
8
|
+
<a href="https://vite-rails.netlify.app/">
|
9
|
+
Vite Rails
|
10
|
+
</a>
|
11
|
+
|
12
|
+
<br>
|
13
|
+
|
3
14
|
<p align="center">
|
4
|
-
|
15
|
+
<a href="https://github.com/ElMassimo/vite_rails/actions">
|
5
16
|
<img alt="Build Status" src="https://github.com/ElMassimo/vite_rails/workflows/build/badge.svg"/>
|
6
|
-
</a>
|
7
|
-
|
17
|
+
</a>
|
18
|
+
<a href="https://codeclimate.com/github/ElMassimo/vite_rails">
|
8
19
|
<img alt="Maintainability" src="https://codeclimate.com/github/ElMassimo/vite_rails/badges/gpa.svg"/>
|
9
20
|
</a>
|
10
21
|
<a href="https://codeclimate.com/github/ElMassimo/vite_rails">
|
11
22
|
<img alt="Test Coverage" src="https://codeclimate.com/github/ElMassimo/vite_rails/badges/coverage.svg"/>
|
12
|
-
</a>
|
23
|
+
</a>
|
13
24
|
<a href="https://rubygems.org/gems/vite_rails">
|
14
25
|
<img alt="Gem Version" src="https://img.shields.io/gem/v/vite_rails.svg?colorB=e9573f"/>
|
15
26
|
</a>
|
@@ -19,26 +30,35 @@
|
|
19
30
|
</p>
|
20
31
|
</h1>
|
21
32
|
|
33
|
+
[website]: https://vite-rails.netlify.app/
|
34
|
+
[configuration reference]: https://vite-rails.netlify.app/config/
|
35
|
+
[features]: https://vite-rails.netlify.app/guide/introduction.html
|
36
|
+
[guides]: https://vite-rails.netlify.app/guide/
|
37
|
+
[config]: https://vite-rails.netlify.app/config/
|
22
38
|
[vite_rails]: https://github.com/ElMassimo/vite_rails
|
23
39
|
[webpacker]: https://github.com/rails/webpacker
|
24
40
|
[vite]: http://vitejs.dev/
|
25
41
|
[config file]: https://github.com/ElMassimo/vite_rails/blob/main/package/default.vite.json
|
42
|
+
[example app]: https://github.com/ElMassimo/vite_rails/tree/main/examples/blog
|
43
|
+
[heroku]: https://vite-rails-demo.herokuapp.com/
|
26
44
|
|
27
|
-
[__Vite Rails__][vite_rails] allows you to use [Vite] to power the frontend.
|
45
|
+
[__Vite Rails__][vite_rails] allows you to use [Vite] to power the frontend of your Rails app.
|
28
46
|
|
29
47
|
[Vite] is to frontend tooling as Ruby to programming, pure joy! 😍
|
30
48
|
|
49
|
+
Check an [example app] running on [Heroku].
|
50
|
+
|
31
51
|
## Features ⚡️
|
32
52
|
|
33
|
-
- 🤖 Automatic
|
34
|
-
- ⚡️
|
35
|
-
-
|
36
|
-
- 🤝 Integrated with <kbd>assets:precompile</kbd>
|
37
|
-
- And more!
|
53
|
+
- 🤖 Automatic entrypoint detection
|
54
|
+
- ⚡️ Blazing fast hot reload
|
55
|
+
- 🚀 Zero-config deployments
|
56
|
+
- 🤝 Integrated with <kbd>assets:precompile</kbd>
|
57
|
+
- [And more!][features]
|
38
58
|
|
39
59
|
## Documentation 📖
|
40
60
|
|
41
|
-
|
61
|
+
Visit the [documentation website][website] to check out the [guides] and searchable [configuration reference].
|
42
62
|
|
43
63
|
## Installation 💿
|
44
64
|
|
@@ -57,74 +77,27 @@ bin/rake vite:install
|
|
57
77
|
|
58
78
|
This will generate configuration files and a sample setup.
|
59
79
|
|
60
|
-
|
61
|
-
|
62
|
-
Drawing inspiration from [webpacker], any files in `app/javascript/entrypoints`
|
63
|
-
will be considered entries to your application (SPAs or pages).
|
80
|
+
Additional installation instructions are available in the [documentation website][website].
|
64
81
|
|
65
|
-
|
66
|
-
for you.
|
82
|
+
## Getting Started 💻
|
67
83
|
|
68
|
-
|
84
|
+
Restart your Rails server, and then run <kbd>bin/vite</kbd> to start the Vite development server.
|
69
85
|
|
70
|
-
|
71
|
-
you to use absolute paths:
|
86
|
+
Add the following your `views/layouts/application.html.erb`:
|
72
87
|
|
73
|
-
```
|
74
|
-
|
75
|
-
|
76
|
-
import '~/channels'
|
77
|
-
|
78
|
-
createApp(App).mount('#app')
|
79
|
-
```
|
80
|
-
|
81
|
-
### Tags 🏷
|
82
|
-
|
83
|
-
`vite_typescript_tag`, `vite_javascript_tag`, and `vite_stylesheet_tag` can be
|
84
|
-
used to output `<script>` and `<link>` tags in your Rails layouts or templates.
|
85
|
-
|
86
|
-
```html
|
87
|
-
<head>
|
88
|
-
<title>Joie</title>
|
89
|
-
<%= csrf_meta_tags %>
|
90
|
-
<%= csp_meta_tag %>
|
91
|
-
|
92
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
93
|
-
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
94
|
-
|
95
|
-
<%= vite_stylesheet_tag 'strange' %>
|
96
|
-
<%= vite_typescript_tag 'application' %>
|
97
|
-
</head>
|
88
|
+
```erb
|
89
|
+
<%= vite_client_tag %>
|
90
|
+
<%= vite_javascript_tag 'application' %>
|
98
91
|
```
|
99
92
|
|
100
|
-
|
101
|
-
|
102
|
-
## Configuration ⚙️
|
103
|
-
|
104
|
-
This is what your `config/vite.json` might look like:
|
105
|
-
|
106
|
-
```json
|
107
|
-
{
|
108
|
-
"all": {
|
109
|
-
"watchAdditionalPaths": []
|
110
|
-
},
|
111
|
-
"development": {
|
112
|
-
"autoBuild": true,
|
113
|
-
"publicOutputDir": "vite-dev",
|
114
|
-
"port": 3036
|
115
|
-
},
|
116
|
-
"test": {
|
117
|
-
"autoBuild": true,
|
118
|
-
"publicOutputDir": "vite-test"
|
119
|
-
}
|
120
|
-
}
|
121
|
-
```
|
93
|
+
Visit any page and you should see a printed console output: `Vite ⚡️ Rails`.
|
122
94
|
|
123
|
-
|
95
|
+
For more [guides] and a full [configuration reference], check the [documentation website][website].
|
124
96
|
|
125
|
-
##
|
97
|
+
## Special Thanks 🙏
|
126
98
|
|
127
99
|
- [webpacker]
|
100
|
+
- [vite]
|
128
101
|
|
129
102
|
## License
|
130
103
|
|
@@ -1,3 +1,10 @@
|
|
1
|
+
// To see this message, add the following to the `<head>` section in your
|
2
|
+
// views/layouts/application.html.erb
|
3
|
+
//
|
4
|
+
// <%= vite_client_tag %>
|
5
|
+
// <%= vite_javascript_tag 'application' %>
|
6
|
+
console.log('Vite ⚡️ Rails')
|
7
|
+
|
1
8
|
// Example: Load Rails libraries in Vite.
|
2
9
|
//
|
3
10
|
// import '@rails/ujs'
|
@@ -11,8 +18,5 @@
|
|
11
18
|
// Turbolinks.start()
|
12
19
|
// ActiveStorage.start()
|
13
20
|
|
14
|
-
// Example: Import a stylesheet in app/
|
21
|
+
// Example: Import a stylesheet in app/frontend/index.css
|
15
22
|
// import '~/index.css'
|
16
|
-
|
17
|
-
console.log('Vite ⚡️ Rails')
|
18
|
-
|
data/lib/install/template.rb
CHANGED
@@ -6,7 +6,7 @@ copy_file "#{ __dir__ }/config/vite.json", ViteRails.config.config_path
|
|
6
6
|
copy_file "#{ __dir__ }/config/vite.config.ts", Rails.root.join('vite.config.ts')
|
7
7
|
|
8
8
|
say 'Creating entrypoints directory'
|
9
|
-
directory "#{ __dir__ }/javascript/entrypoints", ViteRails.config.
|
9
|
+
directory "#{ __dir__ }/javascript/entrypoints", ViteRails.config.resolved_entrypoints_dir
|
10
10
|
|
11
11
|
apply "#{ __dir__ }/binstubs.rb"
|
12
12
|
|
@@ -33,8 +33,8 @@ Dir.chdir(Rails.root) do
|
|
33
33
|
vite_version = package_json.match(/"vite": "(.*)"/)[1]
|
34
34
|
plugin_version = package_json.match(/"vite-plugin-ruby": "(.*)"/)[1]
|
35
35
|
|
36
|
-
say 'Installing vite as
|
37
|
-
run "yarn add vite@#{ vite_version } vite-plugin-ruby@#{ plugin_version }"
|
36
|
+
say 'Installing vite as build dependencies'
|
37
|
+
run "yarn add -D vite@#{ vite_version } vite-plugin-ruby@#{ plugin_version }"
|
38
38
|
end
|
39
39
|
|
40
40
|
say 'Vite ⚡️ Rails successfully installed! 🎉', :green
|
data/lib/tasks/vite/build.rake
CHANGED
@@ -3,21 +3,27 @@
|
|
3
3
|
$stdout.sync = true
|
4
4
|
|
5
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
|
6
12
|
Rake::Task['assets:precompile'].enhance do |task|
|
7
13
|
prefix = task.name.split(/#|assets:precompile/).first
|
8
|
-
|
9
14
|
Rake::Task["#{ prefix }vite:build"].invoke
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
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
|
+
|
14
24
|
desc 'Compile JavaScript packs using vite for production with digests'
|
15
25
|
task build: [:'vite:verify_install', :environment] do
|
16
|
-
ViteRails.
|
17
|
-
ViteRails.ensure_log_goes_to_stdout do
|
18
|
-
ViteRails.build || exit!
|
19
|
-
end
|
20
|
-
end
|
26
|
+
ViteRails.build_from_rake
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
data/lib/tasks/vite/clean.rake
CHANGED
@@ -5,9 +5,7 @@ $stdout.sync = true
|
|
5
5
|
namespace :vite do
|
6
6
|
desc 'Remove old compiled vites'
|
7
7
|
task :clean, [:keep, :age] => [:'vite:verify_install', :environment] do |_, args|
|
8
|
-
ViteRails.
|
9
|
-
ViteRails.clean(keep_up_to: Integer(args.keep || 2), age_in_seconds: Integer(args.age || 3600))
|
10
|
-
end
|
8
|
+
ViteRails.clean_from_rake(args)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
@@ -1,19 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :vite do
|
4
|
-
desc '
|
4
|
+
desc 'Install all JavaScript dependencies as specified via Yarn'
|
5
5
|
task :install_dependencies do
|
6
6
|
valid_node_envs = %w[test development production]
|
7
7
|
node_env = ENV.fetch('NODE_ENV') { valid_node_envs.include?(Rails.env) ? Rails.env : 'production' }
|
8
8
|
Dir.chdir(Rails.root) do
|
9
|
-
|
10
|
-
|
11
|
-
"yarn install #{ v1 ? '--no-progress --frozen-lockfile' : '--immutable' }"
|
12
|
-
elsif Rails.root.join('pnpm-lock.yaml').exist?
|
13
|
-
'pnpm install'
|
14
|
-
else
|
15
|
-
'npm ci'
|
16
|
-
end
|
9
|
+
v1 = `yarn --version`.start_with?('1')
|
10
|
+
install_command = "yarn install #{ v1 ? '--no-progress --frozen-lockfile' : '--immutable' } --production=false"
|
17
11
|
system({ 'NODE_ENV' => node_env }, install_command)
|
18
12
|
end
|
19
13
|
end
|
@@ -11,10 +11,10 @@ namespace :vite do
|
|
11
11
|
WARN
|
12
12
|
exit!
|
13
13
|
end
|
14
|
-
|
15
|
-
|
14
|
+
config_path = Rails.root.join(ViteRails.config.config_path)
|
15
|
+
unless config_path.exist?
|
16
16
|
warn <<~WARN
|
17
|
-
Configuration #{
|
17
|
+
Configuration #{ config_path } file for vite-plugin-ruby not found.
|
18
18
|
Make sure vite:install has run successfully before running dependent tasks.
|
19
19
|
WARN
|
20
20
|
exit!
|
data/lib/vite_rails.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'active_support/
|
3
|
+
require 'rails'
|
4
|
+
require 'active_support/all'
|
5
5
|
|
6
6
|
require 'zeitwerk'
|
7
7
|
loader = Zeitwerk::Loader.for_gem
|
@@ -13,18 +13,10 @@ class ViteRails
|
|
13
13
|
# Internal: Prefix used for environment variables that modify the configuration.
|
14
14
|
ENV_PREFIX = 'VITE_RUBY'
|
15
15
|
|
16
|
-
# Public: Additional environment variables to pass to Vite.
|
17
|
-
#
|
18
|
-
# Example:
|
19
|
-
# ViteRails.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
20
|
-
cattr_accessor(:env) { ENV.select { |key, _| key.start_with?(ENV_PREFIX) } }
|
21
|
-
|
22
|
-
cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
|
23
|
-
|
24
16
|
class << self
|
25
|
-
delegate :config, :builder, :manifest, :commands, :dev_server, :dev_server_running?, to: :instance
|
17
|
+
delegate :config, :builder, :manifest, :commands, :dev_server, :dev_server_running?, :run_proxy?, to: :instance
|
26
18
|
delegate :mode, to: :config
|
27
|
-
delegate :bootstrap, :clean, :clobber, :build, to: :commands
|
19
|
+
delegate :bootstrap, :clean, :clean_from_rake, :clobber, :build, :build_from_rake, to: :commands
|
28
20
|
|
29
21
|
attr_writer :instance
|
30
22
|
|
@@ -37,34 +29,31 @@ class ViteRails
|
|
37
29
|
ViteRails::Runner.new(args).run
|
38
30
|
end
|
39
31
|
|
40
|
-
#
|
41
|
-
def
|
42
|
-
|
43
|
-
rescue StandardError => error
|
44
|
-
logger.error("Failed to check mode for Vite: #{ error.message }")
|
45
|
-
false
|
32
|
+
# Internal: Allows to obtain any env variables for configuration options.
|
33
|
+
def load_env_variables
|
34
|
+
ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
46
35
|
end
|
36
|
+
end
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
ENV['NODE_ENV'] = original
|
54
|
-
end
|
38
|
+
# Public: Additional environment variables to pass to Vite.
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
# ViteRails.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
42
|
+
cattr_accessor(:env) { load_env_variables }
|
55
43
|
|
56
|
-
|
57
|
-
old_logger = ViteRails.logger
|
58
|
-
ViteRails.logger = ActiveSupport::Logger.new(STDOUT)
|
59
|
-
yield
|
60
|
-
ensure
|
61
|
-
ViteRails.logger = old_logger
|
62
|
-
end
|
63
|
-
end
|
44
|
+
cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
|
64
45
|
|
65
46
|
# Public: Returns true if the Vite development server is running.
|
66
47
|
def dev_server_running?
|
67
|
-
|
48
|
+
run_proxy? && dev_server.running?
|
49
|
+
end
|
50
|
+
|
51
|
+
# Public: The proxy for assets should only run in development mode.
|
52
|
+
def run_proxy?
|
53
|
+
config.mode == 'development'
|
54
|
+
rescue StandardError => error
|
55
|
+
ViteRails.logger.error("Failed to check mode for Vite: #{ error.message }")
|
56
|
+
false
|
68
57
|
end
|
69
58
|
|
70
59
|
# Public: Current instance configuration for Vite.
|
data/lib/vite_rails/builder.rb
CHANGED
@@ -67,9 +67,18 @@ private
|
|
67
67
|
def build_with_vite
|
68
68
|
logger.info 'Building with Vite ⚡️'
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
command = "#{ which_ruby } ./bin/vite build --mode #{ config.mode }"
|
71
|
+
stdout, stderr, status = Open3.capture3(ViteRails.config.to_env, command, chdir: File.expand_path(config.root))
|
72
72
|
|
73
|
+
log_build_result(stdout, stderr, status)
|
74
|
+
|
75
|
+
status.success?
|
76
|
+
end
|
77
|
+
|
78
|
+
# Internal: Outputs the build results.
|
79
|
+
#
|
80
|
+
# NOTE: By default it also outputs the manifest entries.
|
81
|
+
def log_build_result(stdout, stderr, status)
|
73
82
|
if status.success?
|
74
83
|
logger.info "Build with Vite complete: #{ config.build_output_dir }"
|
75
84
|
logger.error(stderr.to_s) unless stderr.empty?
|
@@ -78,8 +87,6 @@ private
|
|
78
87
|
non_empty_streams = [stdout, stderr].delete_if(&:empty?)
|
79
88
|
logger.error "Build with Vite failed:\n#{ non_empty_streams.join("\n\n") }"
|
80
89
|
end
|
81
|
-
|
82
|
-
status.success?
|
83
90
|
end
|
84
91
|
|
85
92
|
# Internal: Used to prefix the bin/vite executable file.
|
@@ -101,13 +108,4 @@ private
|
|
101
108
|
config.config_path,
|
102
109
|
].freeze
|
103
110
|
end
|
104
|
-
|
105
|
-
# Internal: Sets additional environment variables for vite-plugin-ruby.
|
106
|
-
def vite_env
|
107
|
-
ViteRails.env.merge(
|
108
|
-
"#{ ViteRails::ENV_PREFIX }_CONFIG_PATH" => config.config_path,
|
109
|
-
"#{ ViteRails::ENV_PREFIX }_MODE" => config.mode,
|
110
|
-
"#{ ViteRails::ENV_PREFIX }_ROOT" => config.root,
|
111
|
-
).transform_values(&:to_s)
|
112
|
-
end
|
113
111
|
end
|