Ruby Rails Webpack 遇到了问题

rain_yym · 2021年10月10日 · 最后由 rain_yym 回复于 2021年10月10日 · 303 次阅读

版本

  • ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
  • Rails 6.0.4.1
  • 数据库使用的 docker
# 
rails new react-app  --webpack=react --database=postgresql

# 
rails g controller pages index

我在路由页面 设置

Rails.application.routes.draw do
  # 根目录
  root 'pages#index'
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

报错显示

Webpacker can't find hello_react in C:/Users/18026/Desktop/react_rails_app/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.

解决方案:

  1. 我尝试搜索答案,但是试了各种方案,没有解决 https://stackoverflow.com/questions/58270161/webpacker-cant-find-application 搜索无果

信息不充足,把项目 push 到 GitHub 让看看源码。

另外 webpacker 已经预定在下个版本移除,没必要现在学。如果要用 webpack 和 react 独立配置即可,不需要 webpakcer。 https://ruby-china.org/topics/41699

Rei 回复

好的,感谢,我是前端 学习一下 rails, 看到有这种融合,就尝试一下,那我就弄个前端脚手架,使用 axios, 麻烦了。

我是一个前端,学习就不使用这种了,使用 api only 模式,谢谢各位

rain_yym 关闭了讨论。 03月19日 21:15
需要 登录 后方可回复, 如果你还没有账号请 注册新账号