前提・実現したいこと
別途質問中のデバッグ中で不明な点が出てきたので、別立てで質問してます。
HTMLページをロード中、コンソールログに表題のエラー(下記に詳細)が出ます。この解消法を教えてください。
"/application-ac851418005bb337fe76.js.map"
はpublic/packs/js/application-ac851418005bb337fe76.js.map
に存在してます。
またブラウザのコンソールからもソースマップエラーが出てます。このmapを探し出せていないようなので(404)なのです。
発生している問題・エラーメッセージ
Started GET "/application-ac851418005bb337fe76.js.map" for 172.17.0.1 at 2019-12-07 08:04:38 +0000 Cannot render console from 172.17.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1 ActionController::RoutingError (No route matches [GET] "/application-ac851418005bb337fe76.js.map"): actionpack (6.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call' web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app' web-console (4.0.1) lib/web_console/middleware.rb:19:in `block in call' web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch' web-console (4.0.1) lib/web_console/middleware.rb:17:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (6.0.1) lib/rails/rack/logger.rb:38:in `call_app' railties (6.0.1) lib/rails/rack/logger.rb:26:in `block in call' activesupport (6.0.1) lib/active_support/tagged_logging.rb:80:in `block in tagged' activesupport (6.0.1) lib/active_support/tagged_logging.rb:28:in `tagged' activesupport (6.0.1) lib/active_support/tagged_logging.rb:80:in `tagged' railties (6.0.1) lib/rails/rack/logger.rb:26:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/request_id.rb:27:in `call' rack (2.0.7) lib/rack/method_override.rb:22:in `call' rack (2.0.7) lib/rack/runtime.rb:22:in `call' activesupport (6.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/static.rb:126:in `call' rack (2.0.7) lib/rack/sendfile.rb:111:in `call' actionpack (6.0.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call' webpacker (4.2.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request' rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call' railties (6.0.1) lib/rails/engine.rb:526:in `call' puma (4.3.0) lib/puma/configuration.rb:228:in `call' puma (4.3.0) lib/puma/server.rb:667:in `handle_request' puma (4.3.0) lib/puma/server.rb:470:in `process_client' puma (4.3.0) lib/puma/server.rb:328:in `block in run' puma (4.3.0) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
ウェブコンソールのエラー
ソースマップエラー: Error: request failed with status 404 リソース URL: http://localhost:3000/?debug=1&format=pdf ソースマップ URL: application-ac851418005bb337fe76.js.map
試したこと
Webpackerを利用している(Rails6のデフォルト)のですが、うまく取り扱えてません。
wicked_pdfのwicked_pdf-1.4.0/lib/wicked_pdf/wicked_pdf_helper/assets.rb
中に後記のヘルパーメソッドが含まれていました。(抜粋)
なので、
<%= wicked_pdf_stylesheet_pack_tag "application" %> <%= wicked_pdf_javascript_pack_tag "application" %>
と
<%= stylesheet_pack_tag 'application' %> <%= javascript_pack_tag 'application' %>
は同値と思っていたのですが、
<%= stylesheet_pack_tag 'application' %>
だと件名のエラーがなく
<%= wicked_pdf_stylesheet_pack_tag "application" %>
だとエラーになります
レンダリングするビュー
$ cat app/views/layouts/pdf.html.erb
html
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="utf-8"> 5 <title>PDF Sample</title> 6 <%= wicked_pdf_stylesheet_pack_tag "application" %> 7 <%= wicked_pdf_javascript_pack_tag "application" %> 8 <!--%= stylesheet_pack_tag 'application' %> 9 <!--%= javascript_pack_tag 'application' %> 10 </head> 11 12 <body> 13 14 <%= yield %> 15 16 </body> 17</html>
require 'open-uri' # If webpacker is used, need to check for version require 'webpacker/version' if defined?(Webpacker) class WickedPdf module WickedPdfHelper module Assets ASSET_URL_REGEX = /url(['"]?([^'"]+?)['"]?)/ def wicked_pdf_stylesheet_pack_tag(*sources) return unless defined?(Webpacker) if running_in_development? stylesheet_pack_tag(*sources) else css_text = sources.collect do |source| source = WickedPdfHelper.add_extension(source, 'css') wicked_pdf_stylesheet_link_tag(webpacker_source_url(source)) end.join("\n") css_text.respond_to?(:html_safe) ? css_text.html_safe : css_text end end def wicked_pdf_javascript_pack_tag(*sources) return unless defined?(Webpacker) if running_in_development? javascript_pack_tag(*sources) else sources.collect do |source| source = WickedPdfHelper.add_extension(source, 'js') "<script type='text/javascript'>#{read_asset(webpacker_source_url(source))}</script>" end.join("\n").html_safe end end def webpacker_source_url(source) return unless defined?(Webpacker) && defined?(Webpacker::VERSION) # In Webpacker 3.2.0 asset_pack_url is introduced if Webpacker::VERSION >= '3.2.0' asset_pack_url(source) else source_path = asset_pack_path(source) # Remove last slash from root path root_url[0...-1] + source_path end end def running_in_development? return unless defined?(Webpacker) # :dev_server method was added in webpacker 3.0.0 if Webpacker.respond_to?(:dev_server) Webpacker.dev_server.running? else Rails.env.development? || Rails.env.test? end end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/07 12:18
2019/12/08 00:29
2019/12/08 12:50