Using the default configuration of rails/webpacker I could not read a file through the <%= asset_pack_path 'images/calendar.png' %>
helper in a view. Reading the docs it seems easy to do, but something goes wrong trying access the page:
使用rails / webpacker的默认配置,我无法通过视图中的<%= asset_pack_path'images / calendar.png'%>帮助程序读取文件。阅读文档似乎很容易,但尝试访问页面时出现问题:
Webpacker can't find application.css in /path/manifest.json. Possible causes:
Webpacker在/path/manifest.json中找不到application.css。可能的原因:
- 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.- 除非使用webpack -w或webpack-dev-server,否则您希望将环境的webpacker.yml值设置为true。
- Webpack has not yet re-run to reflect updates.
- Webpack尚未重新运行以反映更新。
- You have misconfigured Webpacker's config/webpacker.yml file.
- 您配置错误的Webpacker的config / webpacker.yml文件。
- Your Webpack configuration is not creating a manifest. Your manifest contains:
- 您的Webpack配置未创建清单。您的清单包含:
Am I missing some configuration?
我错过了一些配置吗?
1 个解决方案
#1
1
It seems a docs misundertand as the awnser:
这似乎是一个文档误解和作为awnser:
asset_pack_path only references assets used as pack (i.e. JS packs file) or assets used inside a pack like a font, image or styles referenced that's why it's not present inside manifest.json. asset_pack_path doesn't look inside any folder like rails view helpers for assets.
asset_pack_path仅引用用作包的资产(即JS包文件)或包内使用的资产,如引用的字体,图像或样式,这就是manifest.json中不存在的原因。 asset_pack_path不会查看任何文件夹,例如rails视图帮助程序的资产。
Perhaps use Rails image_path helper if you want to reference images that’s not used inside packs.
如果要引用包内未使用的图像,也许可以使用Rails image_path帮助程序。
#1
1
It seems a docs misundertand as the awnser:
这似乎是一个文档误解和作为awnser:
asset_pack_path only references assets used as pack (i.e. JS packs file) or assets used inside a pack like a font, image or styles referenced that's why it's not present inside manifest.json. asset_pack_path doesn't look inside any folder like rails view helpers for assets.
asset_pack_path仅引用用作包的资产(即JS包文件)或包内使用的资产,如引用的字体,图像或样式,这就是manifest.json中不存在的原因。 asset_pack_path不会查看任何文件夹,例如rails视图帮助程序的资产。
Perhaps use Rails image_path helper if you want to reference images that’s not used inside packs.
如果要引用包内未使用的图像,也许可以使用Rails image_path帮助程序。