-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better message if server asset compile fails #292
Comments
When it didn't work: RSpec.configure do |config|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
# ...
end ReactOnRails.configure do |config|
config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js"
# ...
end Did some digging in the source, found the code looking at whether # Set the server_bundle_js_file to "" if you know that you will not be server rendering. That did the trick. |
We need an else condition here if the file is not found and we should check that the file is not blank. def initialize(server_bundle_js_file: nil, prerender: nil, replay_console: nil,
trace: nil, development_mode: nil,
logging_on_server: nil, server_renderer_pool_size: nil,
server_renderer_timeout: nil, raise_on_prerender_error: nil,
skip_display_none: nil, generated_assets_dirs: DEFAULT_GENERATED_ASSETS_DIRS)
self.server_bundle_js_file = if File.exist?(server_bundle_js_file)
server_bundle_js_file
end We can add a check here: Instead of just: fail "Error in building assets!\n#{build_output}" unless Utils.last_process_completed_successfully? We need something like: unless Utils.last_process_completed_successfully?
msg = "Error in building assets!\n#{build_output}"
msg << "Check your react_on_rails.rb initializer to set `config.server_bundle_js_file` to blank if you are not using server rendering" if Utils.server_rendering_is_enabled? && build_output =~ /server/
fail msg Later for the next major version bumpWe should also change the default for the def self.configuration
@configuration ||= Configuration.new(
generated_assets_dirs: DEFAULT_GENERATED_ASSETS_DIRS,
server_bundle_js_file: File.join(*%w(app assets javascripts generated server.js)), We need to do this once we have some other "breaking changes". |
Also, when you run the install, wouldn't it be possible to default the server js to empty when someone uses |
Bingo. Here's the main bug: # Shown below are the defaults for configuration
ReactOnRails.configure do |config|
# Client bundles are configured in application.js
# Server rendering:
# Server bundle is a single file for all server rendering of components.
config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js" |
First part fixed in Release 3.0.4. |
We can re-open a new issue if there's more to do here. |
If somebody is doing client side only rendering, maybe we shouldn't have a default for the server side rendering setup?
Maybe we can make this a bit smarter?
@ernie Any more details? do you have the samples of your config when it didn't work and what error message you saw?
The text was updated successfully, but these errors were encountered: