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
data/test/dev_server_test.rb
CHANGED
@@ -6,34 +6,4 @@ class DevServerTest < ViteRails::Test
|
|
6
6
|
def test_running?
|
7
7
|
refute ViteRails.dev_server.running?
|
8
8
|
end
|
9
|
-
|
10
|
-
def test_host
|
11
|
-
with_rails_env('development') do
|
12
|
-
assert_equal ViteRails.config.host, 'localhost'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_port
|
17
|
-
with_rails_env('development') do
|
18
|
-
assert_equal ViteRails.config.port, 3035
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_https?
|
23
|
-
with_rails_env('development') do
|
24
|
-
assert_equal ViteRails.config.https, false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_protocol
|
29
|
-
with_rails_env('development') do
|
30
|
-
assert_equal ViteRails.config.protocol, 'http'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_host_with_port
|
35
|
-
with_rails_env('development') do
|
36
|
-
assert_equal ViteRails.config.host_with_port, 'localhost:3035'
|
37
|
-
end
|
38
|
-
end
|
39
9
|
end
|
@@ -4,39 +4,78 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class EngineRakeTasksTest < Minitest::Test
|
6
6
|
def setup
|
7
|
-
|
7
|
+
remove_vite_files
|
8
8
|
end
|
9
9
|
|
10
10
|
def teardown
|
11
|
-
|
11
|
+
remove_vite_files
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
output =
|
14
|
+
def test_tasks_mounted
|
15
|
+
output = within_mounted_app { `bundle exec rake -T` }
|
16
16
|
assert_includes output, 'app:vite'
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
19
|
+
def test_rake_tasks
|
20
|
+
within_mounted_app { `bundle exec rake app:vite:binstubs` }
|
21
|
+
assert vite_binstub_path.exist?
|
22
|
+
|
23
|
+
within_mounted_app { `bundle exec rake app:vite:install` }
|
24
|
+
assert vite_config_ts_path.exist?
|
25
|
+
assert app_frontend_dir.exist?
|
26
|
+
|
27
|
+
within_mounted_app { `bundle exec rake app:vite:build` }
|
28
|
+
assert app_public_dir.exist?
|
29
|
+
assert app_public_dir.join('manifest.json').exist?
|
30
|
+
assert app_public_dir.join('assets').exist?
|
31
|
+
|
32
|
+
within_mounted_app { `bundle exec rake app:vite:clean` }
|
33
|
+
assert app_public_dir.join('manifest.json').exist? # Still fresh
|
34
|
+
|
35
|
+
within_mounted_app { `bundle exec rake app:vite:clean[0,0]` }
|
36
|
+
refute app_public_dir.join('manifest.json').exist?
|
37
|
+
|
38
|
+
within_mounted_app { `bundle exec rake app:vite:clobber` }
|
39
|
+
refute app_public_dir.exist?
|
40
|
+
rescue Minitest::Assertion => error
|
41
|
+
raise error, [error.message, @command_results.join("\n\n")].join("\n")
|
22
42
|
end
|
23
43
|
|
24
44
|
private
|
25
45
|
|
46
|
+
def within_mounted_app
|
47
|
+
Dir.chdir(mounted_app_path) { yield }.tap { |result| @command_results << result }
|
48
|
+
end
|
49
|
+
|
26
50
|
def mounted_app_path
|
27
|
-
File.expand_path('mounted_app'
|
51
|
+
Pathname.new(File.expand_path(__dir__)).join('mounted_app')
|
52
|
+
end
|
53
|
+
|
54
|
+
def root_dir
|
55
|
+
mounted_app_path.join('test/dummy')
|
56
|
+
end
|
57
|
+
|
58
|
+
def vite_binstub_path
|
59
|
+
root_dir.join('bin/vite')
|
60
|
+
end
|
61
|
+
|
62
|
+
def vite_config_ts_path
|
63
|
+
root_dir.join('vite.config.ts')
|
64
|
+
end
|
65
|
+
|
66
|
+
def app_frontend_dir
|
67
|
+
root_dir.join('app/frontend')
|
28
68
|
end
|
29
69
|
|
30
|
-
def
|
31
|
-
|
32
|
-
"#{ mounted_app_path }/test/dummy/bin/vite",
|
33
|
-
"#{ mounted_app_path }/test/dummy/bin/vite-dev-server",
|
34
|
-
]
|
70
|
+
def app_public_dir
|
71
|
+
root_dir.join('public/vite-dev')
|
35
72
|
end
|
36
73
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
74
|
+
def remove_vite_files
|
75
|
+
vite_binstub_path.delete if vite_binstub_path.exist?
|
76
|
+
vite_config_ts_path.delete if vite_config_ts_path.exist?
|
77
|
+
app_frontend_dir.rmtree if app_frontend_dir.exist?
|
78
|
+
app_public_dir.rmtree if app_public_dir.exist?
|
79
|
+
@command_results = []
|
41
80
|
end
|
42
81
|
end
|
data/test/helper_test.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class HelperTest < ActionView::TestCase
|
6
|
+
include ViteRailsTestHelpers
|
7
|
+
|
6
8
|
tests ViteRails::Helper
|
7
9
|
|
8
10
|
attr_reader :request
|
@@ -17,122 +19,52 @@ class HelperTest < ActionView::TestCase
|
|
17
19
|
end.new
|
18
20
|
end
|
19
21
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def test_asset_pack_url
|
26
|
-
assert_equal 'https://example.com/packs/bootstrap-300631c4f0e0f9c865bc.js', asset_pack_url('bootstrap.js')
|
27
|
-
assert_equal 'https://example.com/packs/bootstrap-c38deda30895059837cf.css', asset_pack_url('bootstrap.css')
|
22
|
+
def test_vite_client_tag
|
23
|
+
assert_nil vite_client_tag
|
24
|
+
with_dev_server_running {
|
25
|
+
assert_equal '<script src="/vite-production/@vite/client" type="module"></script>', vite_client_tag
|
26
|
+
}
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
31
|
-
assert_equal '/
|
32
|
-
assert_equal '/
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def test_vite_asset_path
|
30
|
+
assert_equal '/vite-production/assets/colored.1173bfe0.js', vite_asset_path('colored.js')
|
31
|
+
assert_equal '/vite-production/assets/colored.84277fd6.css', vite_asset_path('colored.css')
|
32
|
+
with_dev_server_running {
|
33
|
+
assert_equal '/vite-production/colored.js', vite_asset_path('colored.js')
|
34
|
+
assert_equal '/vite-production/colored.css', vite_asset_path('colored.css')
|
35
|
+
}
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
assert_equal
|
40
|
-
|
41
|
-
assert_equal 'https://example.com/packs/media/images/image-c38deda30895059837cf.jpg', image_pack_url('media/images/image.jpg')
|
42
|
-
assert_equal 'https://example.com/packs/media/images/nested/image-c38deda30895059837cf.jpg', image_pack_url('nested/image.jpg')
|
43
|
-
assert_equal 'https://example.com/packs/media/images/nested/image-c38deda30895059837cf.jpg', image_pack_url('media/images/nested/image.jpg')
|
44
|
-
end
|
38
|
+
def test_vite_stylesheet_tag
|
39
|
+
assert_equal %(<link rel="stylesheet" media="screen" href="/vite-production/assets/colored.84277fd6.css" />),
|
40
|
+
vite_stylesheet_tag('colored')
|
45
41
|
|
46
|
-
|
47
|
-
assert_equal \
|
48
|
-
'<img alt="Edit Entry" src="/packs/application-k344a6d59eef8632c9d1.png" width="16" height="10" />',
|
49
|
-
image_pack_tag('application.png', size: '16x10', alt: 'Edit Entry')
|
50
|
-
assert_equal \
|
51
|
-
'<img alt="Edit Entry" src="/packs/media/images/image-c38deda30895059837cf.jpg" width="16" height="10" />',
|
52
|
-
image_pack_tag('image.jpg', size: '16x10', alt: 'Edit Entry')
|
53
|
-
assert_equal \
|
54
|
-
'<img alt="Edit Entry" src="/packs/media/images/image-c38deda30895059837cf.jpg" width="16" height="10" />',
|
55
|
-
image_pack_tag('media/images/image.jpg', size: '16x10', alt: 'Edit Entry')
|
56
|
-
assert_equal \
|
57
|
-
'<img alt="Edit Entry" src="/packs/media/images/nested/image-c38deda30895059837cf.jpg" width="16" height="10" />',
|
58
|
-
image_pack_tag('nested/image.jpg', size: '16x10', alt: 'Edit Entry')
|
59
|
-
assert_equal \
|
60
|
-
'<img alt="Edit Entry" src="/packs/media/images/nested/image-c38deda30895059837cf.jpg" width="16" height="10" />',
|
61
|
-
image_pack_tag('media/images/nested/image.jpg', size: '16x10', alt: 'Edit Entry')
|
62
|
-
assert_equal \
|
63
|
-
'<img srcset="/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg 2x" src="/packs/media/images/image-c38deda30895059837cf.jpg" />',
|
64
|
-
image_pack_tag('media/images/image.jpg', srcset: { 'media/images/image-2x.jpg' => '2x' })
|
65
|
-
end
|
42
|
+
assert_equal vite_stylesheet_tag('colored'), vite_stylesheet_tag('colored.css')
|
66
43
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
favicon_pack_tag('application.png', rel: 'apple-touch-icon', type: 'image/png')
|
71
|
-
assert_equal \
|
72
|
-
'<link rel="apple-touch-icon" type="image/png" href="/packs/media/images/mb-icon-c38deda30895059837cf.png" />',
|
73
|
-
favicon_pack_tag('mb-icon.png', rel: 'apple-touch-icon', type: 'image/png')
|
74
|
-
assert_equal \
|
75
|
-
'<link rel="apple-touch-icon" type="image/png" href="/packs/media/images/mb-icon-c38deda30895059837cf.png" />',
|
76
|
-
favicon_pack_tag('media/images/mb-icon.png', rel: 'apple-touch-icon', type: 'image/png')
|
77
|
-
assert_equal \
|
78
|
-
'<link rel="apple-touch-icon" type="image/png" href="/packs/media/images/nested/mb-icon-c38deda30895059837cf.png" />',
|
79
|
-
favicon_pack_tag('nested/mb-icon.png', rel: 'apple-touch-icon', type: 'image/png')
|
80
|
-
assert_equal \
|
81
|
-
'<link rel="apple-touch-icon" type="image/png" href="/packs/media/images/nested/mb-icon-c38deda30895059837cf.png" />',
|
82
|
-
favicon_pack_tag('media/images/nested/mb-icon.png', rel: 'apple-touch-icon', type: 'image/png')
|
83
|
-
end
|
44
|
+
with_dev_server_running {
|
45
|
+
assert_equal %(<link rel="stylesheet" media="screen" href="/vite-production/colored.css" />),
|
46
|
+
vite_stylesheet_tag('colored')
|
84
47
|
|
85
|
-
|
86
|
-
|
87
|
-
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js"></script>),
|
88
|
-
javascript_pack_tag('bootstrap.js')
|
48
|
+
assert_equal vite_stylesheet_tag('colored'), vite_stylesheet_tag('colored.css')
|
49
|
+
}
|
89
50
|
end
|
90
51
|
|
91
|
-
def
|
92
|
-
assert_equal
|
93
|
-
%(<script src="/
|
94
|
-
|
95
|
-
|
52
|
+
def test_vite_javascript_tag
|
53
|
+
assert_equal [
|
54
|
+
%(<script src="/vite-production/assets/application.a0ba047e.js" crossorigin="anonymous" type="module"></script>),
|
55
|
+
%(<link rel="preload" href="/vite-production/assets/example_import.8e1fddc0.js" as="script" type="text/javascript" crossorigin="anonymous">),
|
56
|
+
%(<link rel="stylesheet" media="screen" href="/vite-production/assets/application.cccfef34.css" />),
|
57
|
+
].join, vite_javascript_tag('application')
|
96
58
|
|
97
|
-
|
98
|
-
assert_equal
|
99
|
-
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js" defer="defer"></script>\n) +
|
100
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>),
|
101
|
-
javascript_pack_tag('bootstrap.js', 'application.js', defer: true)
|
102
|
-
end
|
59
|
+
assert_equal vite_javascript_tag('application'), vite_javascript_tag('application.js')
|
60
|
+
assert_equal vite_javascript_tag('application'), vite_typescript_tag('application')
|
103
61
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js"></script>\n) +
|
108
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js"></script>),
|
109
|
-
javascript_packs_with_chunks_tag('application')
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_stylesheet_pack_tag_split_chunks
|
113
|
-
assert_equal \
|
114
|
-
%(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
|
115
|
-
%(<link rel="stylesheet" media="screen" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" />\n) +
|
116
|
-
%(<link rel="stylesheet" media="screen" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" />),
|
117
|
-
stylesheet_packs_with_chunks_tag('application', 'hello_stimulus')
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_stylesheet_pack_tag
|
121
|
-
assert_equal \
|
122
|
-
%(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
|
123
|
-
stylesheet_pack_tag('bootstrap.css')
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_stylesheet_pack_tag_symbol
|
127
|
-
assert_equal \
|
128
|
-
%(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
|
129
|
-
stylesheet_pack_tag(:bootstrap)
|
130
|
-
end
|
62
|
+
with_dev_server_running {
|
63
|
+
assert_equal %(<script src="/vite-production/application.js" crossorigin="anonymous" type="module"></script>),
|
64
|
+
vite_javascript_tag('application')
|
131
65
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
%(<link rel="stylesheet" media="all" href="/packs/application-dd6b1cd38bfa093df600.css" />),
|
136
|
-
stylesheet_pack_tag('bootstrap.css', 'application.css', media: 'all')
|
66
|
+
assert_equal %(<script src="/vite-production/application.ts" crossorigin="anonymous" type="module"></script>),
|
67
|
+
vite_typescript_tag('application')
|
68
|
+
}
|
137
69
|
end
|
138
70
|
end
|
data/test/manifest_test.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ManifestTest <
|
5
|
+
class ManifestTest < ViteRails::Test
|
6
6
|
def test_lookup_exception!
|
7
7
|
asset_file = 'calendar.js'
|
8
8
|
|
@@ -10,7 +10,7 @@ class ManifestTest < Minitest::Test
|
|
10
10
|
ViteRails.manifest.lookup!(asset_file)
|
11
11
|
end
|
12
12
|
|
13
|
-
assert_match "
|
13
|
+
assert_match "Vite Rails can't find #{ asset_file } in #{ manifest_path }", error.message
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_lookup_with_type_exception!
|
@@ -20,56 +20,60 @@ class ManifestTest < Minitest::Test
|
|
20
20
|
ViteRails.manifest.lookup!(asset_file, type: :javascript)
|
21
21
|
end
|
22
22
|
|
23
|
-
assert_match "
|
23
|
+
assert_match "Vite Rails can't find #{ asset_file }.js in #{ manifest_path }", error.message
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_lookup_success!
|
27
|
-
|
27
|
+
entry = {
|
28
|
+
'file' => '/vite-production/assets/application.a0ba047e.js',
|
29
|
+
'imports' => [
|
30
|
+
'/vite-production/assets/example_import.8e1fddc0.js',
|
31
|
+
],
|
32
|
+
}
|
33
|
+
assert_equal entry, ViteRails.manifest.lookup!('application.js', type: :javascript)
|
34
|
+
assert_equal entry, ViteRails.manifest.lookup!('application', type: :typescript)
|
28
35
|
end
|
29
36
|
|
30
|
-
def
|
31
|
-
|
37
|
+
def test_lookup_success_with_dev_server_running!
|
38
|
+
entry = { 'file' => '/vite-production/application.js' }
|
39
|
+
with_dev_server_running {
|
40
|
+
assert_equal entry, ViteRails.manifest.lookup!('application.js')
|
41
|
+
}
|
42
|
+
entry = { 'file' => '/vite-production/application.ts' }
|
43
|
+
with_dev_server_running {
|
44
|
+
assert_equal entry, ViteRails.manifest.lookup!('application', type: :typescript)
|
45
|
+
}
|
32
46
|
end
|
33
47
|
|
34
|
-
def
|
35
|
-
assert_nil ViteRails.manifest.
|
48
|
+
def test_lookup_nil
|
49
|
+
assert_nil ViteRails.manifest.lookup('foo.js')
|
36
50
|
end
|
37
51
|
|
38
52
|
def test_lookup_success
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
asset_file = 'calendar'
|
44
|
-
|
45
|
-
error = assert_raises_manifest_missing_entry_error do
|
46
|
-
ViteRails.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
|
47
|
-
end
|
48
|
-
|
49
|
-
assert_match "ViteRails can't find #{ asset_file }.js in #{ manifest_path }", error.message
|
53
|
+
entry = { 'file' => '/vite-production/assets/application.cccfef34.css', 'imports' => nil }
|
54
|
+
assert_equal entry, ViteRails.manifest.lookup('application.css')
|
55
|
+
assert_equal entry, ViteRails.manifest.lookup('application.css', type: :stylesheet)
|
56
|
+
assert_equal entry, ViteRails.manifest.lookup('application', type: :stylesheet)
|
50
57
|
end
|
51
58
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
]
|
58
|
-
|
59
|
-
assert_equal ViteRails.manifest.lookup_pack_with_chunks!('application', type: :javascript), application_entrypoints
|
59
|
+
def test_lookup_success_with_dev_server_running
|
60
|
+
entry = { 'file' => '/vite-production/application.css' }
|
61
|
+
with_dev_server_running {
|
62
|
+
assert_equal entry, ViteRails.manifest.lookup('application', type: :stylesheet)
|
63
|
+
}
|
60
64
|
end
|
61
65
|
|
62
66
|
private
|
63
67
|
|
64
68
|
def assert_raises_manifest_missing_entry_error(&block)
|
65
69
|
error = nil
|
66
|
-
ViteRails.config.stub :
|
70
|
+
ViteRails.config.stub :auto_build, false do
|
67
71
|
error = assert_raises ViteRails::Manifest::MissingEntryError, &block
|
68
72
|
end
|
69
73
|
error
|
70
74
|
end
|
71
75
|
|
72
76
|
def manifest_path
|
73
|
-
File.expand_path File.join(File.dirname(__FILE__), 'test_app/public/
|
77
|
+
File.expand_path File.join(File.dirname(__FILE__), 'test_app/public/vite-production', 'manifest.json').to_s
|
74
78
|
end
|
75
79
|
end
|
data/test/mode_test.rb
CHANGED
@@ -3,19 +3,14 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class ModeTest < ViteRails::Test
|
6
|
-
def
|
7
|
-
assert_equal ViteRails.config.mode
|
6
|
+
def test_mode
|
7
|
+
assert_equal Rails.env, ViteRails.config.mode
|
8
|
+
assert_equal ViteRails.config.mode, ViteRails.mode
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
with_rails_env('
|
12
|
-
assert_equal
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_custom_with_config
|
17
|
-
with_rails_env('staging') do
|
18
|
-
assert_equal ViteRails.config.mode, 'staging'
|
11
|
+
def test_mode_with_rails_env
|
12
|
+
with_rails_env('staging') do |config|
|
13
|
+
assert_equal 'staging', config.mode
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
@@ -1,20 +1,14 @@
|
|
1
1
|
{
|
2
|
+
"all": {
|
3
|
+
"watchAdditionalPaths": []
|
4
|
+
},
|
2
5
|
"development": {
|
3
6
|
"autoBuild": true,
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"publicOutputDir": "vite-development"
|
7
|
+
"publicOutputDir": "vite-dev",
|
8
|
+
"port": 3036
|
7
9
|
},
|
8
10
|
"test": {
|
9
11
|
"autoBuild": true,
|
10
12
|
"publicOutputDir": "vite-test"
|
11
|
-
},
|
12
|
-
"production": {
|
13
|
-
"autoBuild": false,
|
14
|
-
"publicOutputDir": "vite-production"
|
15
|
-
},
|
16
|
-
"staging": {
|
17
|
-
"autoBuild": false,
|
18
|
-
"publicOutputDir": "vite-staging"
|
19
13
|
}
|
20
14
|
}
|