ruby-on-rails - Rails 中如何使用“manifest.json”
问题描述
manifest.json
文件:预编译资产和指纹资产之间的映射。
我明白它是什么,但它是如何使用的?
在 Webpacker 设置中,有一条评论指出
# Cache manifest.json for performance
好的,但是什么工作是manifest.json
执行缓存它使它更快?
解决方案
Webpacker::Manifest为我们提供了这些信息。
# Singleton registry for accessing the packs path using a generated manifest.
# This allows javascript_pack_tag, stylesheet_pack_tag, asset_pack_path to take a reference to,
# say, "calendar.js" or "calendar.css" and turn it into "/packs/calendar-1016838bab065ae1e314.js" or
# "/packs/calendar-1016838bab065ae1e314.css".
#
# When the configuration is set to on-demand compilation, with the `compile: true` option in
# the webpacker.yml file, any lookups will be preceded by a compilation if one is needed.
当 Rails 想要calendar.js
manifest.json 时说要在/packs/calendar-1016838bab065ae1e314.js
. 稍后在代码中有一个示例。
Webpacker.manifest.lookup('calendar.js') # => "/packs/calendar-1016838bab065ae1e122.js"
推荐阅读
- python - Airflow:创建一次性动态 SubDag
- python - 使用 GPU 运行 Keras/Theano
- templates - 键入 trait 以检查 Eigen 类型是表达式(无存储)还是矩阵或数组(有存储)?
- bash - Dockerfile 不会替换文本,但命令行会,可能的错误?
- google-calendar-api - Google Calendar API - 更深入地了解日历使用限制超出错误
- python-3.x - 构建失败:没有名为 virtualenv 的模块
- c++ - 错误 C2440:“=”:无法从“const char *”转换为“LPCWSTR”
- python - 如何通过 Windows 身份验证将 JSON 导入 Pandas 数据框
- ios - 您的应用使用“prefs:root=”非公共 URL 方案。更新旧代码的最佳计划?
- c++ - 安装 OPEN-MPI 时的问题