Skip to content

Commit c46d751

Browse files
timonbanditgauravtiwari
authored andcommitted
asset_pack_path + HMR fix; Closes #1171 (#1172)
1 parent da3cd10 commit c46d751

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/webpacker/helper.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ module Webpacker::Helper
55
#
66
# Example:
77
#
8+
# # In development mode with hot module replacement:
9+
# <%= asset_pack_path 'calendar.css' %> # => nil
10+
#
11+
# # In production mode:
812
# <%= asset_pack_path 'calendar.css' %> # => "/packs/calendar-1016838bab065ae1e122.css"
913
def asset_pack_path(name, **options)
10-
asset_path(Webpacker.manifest.lookup!(name), **options)
14+
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?
15+
asset_path(Webpacker.manifest.lookup!(name), **options)
16+
end
1117
end
1218

1319
# Computes the absolute path for a given Webpacker asset.
@@ -16,9 +22,15 @@ def asset_pack_path(name, **options)
1622
#
1723
# Example:
1824
#
25+
# # In development mode with hot module replacement:
26+
# <%= asset_pack_url 'calendar.css' %> # => nil
27+
#
28+
# # In production mode:
1929
# <%= asset_pack_url 'calendar.css' %> # => "http://example.com/packs/calendar-1016838bab065ae1e122.css"
2030
def asset_pack_url(name, **options)
21-
asset_url(Webpacker.manifest.lookup!(name), **options)
31+
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?
32+
asset_url(Webpacker.manifest.lookup!(name), **options)
33+
end
2234
end
2335

2436
# Creates a script tag that references the named pack file, as compiled by webpack per the entries list

0 commit comments

Comments
 (0)