-
-
Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathwebpack_assets_compiler.rb
38 lines (31 loc) · 1.27 KB
/
webpack_assets_compiler.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
# You can replace this implementation with your own for use by the
# ReactOnRails::TestHelper.ensure_assets_compiled helper
module ReactOnRails
module TestHelper
class WebpackAssetsCompiler
def compile_assets
if ReactOnRails.configuration.build_test_command.blank?
msg = <<~MSG
You are using the React on Rails test helper.
Either you used:
ReactOnRails::TestHelper.configure_rspec_to_compile_assets or
ReactOnRails::TestHelper.ensure_assets_compiled
but you did not specify the config.build_test_command
React on Rails is aborting your test run
If you wish to use the config/#{ReactOnRails::PackerUtils.packer_type}.yml compile option for tests
them remove your call to the ReactOnRails test helper.
MSG
puts Rainbow(msg).red
exit!(1)
end
puts "\nBuilding Webpack assets..."
cmd = ReactOnRails::Utils.prepend_cd_node_modules_directory(
ReactOnRails.configuration.build_test_command
)
ReactOnRails::Utils.invoke_and_exit_if_failed(cmd, "Error in building webpack assets!")
puts "Completed building Webpack assets."
end
end
end
end