reactjs - 使用 rails 5.2.4.4 设置 react_on_rails 时出现图像编译错误
问题描述
使用 react_on_rails 和 rails 5.2.4.4
我正进入(状态:
ERROR in SERVER PRERENDERING
Encountered error: "Error: Cannot find module 'images/Rectangle.png'"
when prerendering
使用 config/initializers/react_on_rails.rb :
# frozen_string_literal: true
# See https://github.com/shakacode/react_on_rails/blob/master/docs/basics/configuration.md
# for many more options.
ReactOnRails.configure do |config|
# This configures the script to run to build the production assets by webpack. Set this to nil
# if you don't want react_on_rails building this file for you.
# If nil, then the standard rails/webpacker assets:precompile will run
# config.build_production_command = nil
################################################################################
################################################################################
# TEST CONFIGURATION OPTIONS
# Below options are used with the use of this test helper:
# ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
################################################################################
# If you are using this in your spec_helper.rb (or rails_helper.rb):
#
# ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
#
# with rspec then this controls what yarn command is run
# to automatically refresh your webpack assets on every test run.
#
# Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
# and set the config/webpacker.yml option for test to true.
config.build_test_command = "RAILS_ENV=test bin/webpack"
################################################################################
################################################################################
# SERVER RENDERING OPTIONS
################################################################################
# This is the file used for server rendering of React when using `(prerender: true)`
# If you are never using server rendering, you should set this to "".
# Note, there is only one server bundle, unlike JavaScript where you want to minimize the size
# of the JS sent to the client. For the server rendering, React on Rails creates a pool of
# JavaScript execution instances which should handle any component requested.
#
# While you may configure this to be the same as your client bundle file, this file is typically
# different. You should have ONE server bundle which can create all of your server rendered
# React components.
#
config.server_bundle_js_file = "hello-world-bundle.js"
end
如果我使用文档中的配置。然后我得到:
没有这样的文件或目录@rb_file_s_mtime
解决方案
推荐阅读
- angular - 如何更改 Angular CLI 用于生成测试的根目录?
- javascript - Angular 2 - 更改嵌套表单输入值
- javascript - 传递消息时通过 iframe 引发错误的 Chrome 扩展程序中的沙盒页面
- sql - Oracle 透视/解码
- ios - 将 TextView 滚动到顶部
- kubernetes - 如何使用 DNS 发现 (SRV) 在 Kubernetes 中设置 ETCD 集群?
- android - 如何在android中制作像Uber这样的地点选择器?
- arrays - 声明和使用静态常量数组
- java - MapBox LocationEngineProvider
- php - 为什么在运行命令、调用程序时,XMLSERVICE 调用不使用经过身份验证的用户?