我开始了一个新项目。它使用 phlex-rails、phlex_ui 和 tailwindcss-rails,以及 Rails 默认提供的大量常用内容。这一次,我想了解更多有关 Rails 7 和 importmap 的知识。
每当我获得一个页面时,该页面都会加载几秒钟,然后正确显示。查看日志时,我看到许多文件的 GET 请求:
Started GET "/assets/sub/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subBusinessDays/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subDays/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subHours/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subISOWeekYears/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subMilliseconds/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subMinutes/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/subMonths/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
我猜这些是正常的,因为资产管道不存在。我本来希望这些文件会被缓存,但这并不重要。
重要的是这些:
Started GET "/assets/weeksToDays/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/yearsToMonths/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/yearsToQuarters/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/_/a28ffa54.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/_/d2e90c22.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/_lib/toInteger/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/assets/_lib/getTimezoneOffsetInMilliseconds/index.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/_/bdf2ba0c.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
ActionController::RoutingError (No route matches [GET] "/_/a28ffa54.js"):
ActionController::RoutingError (No route matches [GET] "/_/d2e90c22.js"):
Started GET "/_/43b08ee2.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
ActionController::RoutingError (No route matches [GET] "/_/bdf2ba0c.js"):
Started GET "/_/18a96f2b.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/_/35814e45.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
Started GET "/_/9f5bb25a.js" for 127.0.0.1 at 2024-04-16 09:46:08 -0400
ActionController::RoutingError (No route matches [GET] "/_/43b08ee2.js"):
ActionController::RoutingError (No route matches [GET] "/_/18a96f2b.js"):
注意路由错误:
No route matches [GET] "/_/18a96f2b.js"
。
我想知道这些错误是关于什么的。
我很难在网上搜索这些错误,因为路径似乎是某种哈希?任何指点表示赞赏!
importmap-rails v2
目前已损坏,因为一项更改为始终下载文件而不是使用 cdn:降级到
v1
似乎是目前最简单的路径:
# Gemfile
gem "importmap-rails", "~> 1.2"
然后再次钉住您的包裹
bin/importmap pin
。
...但您也可以手动指向 CDN。或者使用 1.2.x.
https://github.com/rails/importmap-rails/issues/230#issuecomment-1906207824