"manifest.json" 如何在 Rails 中使用
How is "manifest.json" used in in Rails
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"
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"