Skip to content

Commit 7723154

Browse files
committed
Remove app/packs from the autoload paths
Closes #3090.
1 parent 859f69a commit 7723154

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lib/webpacker/railtie.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ class Webpacker::Engine < ::Rails::Engine
5151
app.config.javascript_path = Webpacker.config.source_path.relative_path_from(Rails.root.join("app")).to_s
5252
end
5353
end
54+
55+
initializer "webpacker.remove_app_packs_from_the_autoload_paths" do
56+
Rails.application.config.before_initialize do
57+
source_path = Webpacker.config.source_path.to_s
58+
ActiveSupport::Dependencies.autoload_paths.delete(source_path)
59+
end
60+
end
5461
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$test_app_autoload_paths_in_initializer = ActiveSupport::Dependencies.autoload_paths

test/webpacker_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ def dev_server.running?; true; end
2727
assert Webpacker.inlining_css?
2828
end
2929
end
30+
31+
def test_app_autoload_paths_cleanup
32+
assert_empty $test_app_autoload_paths_in_initializer
33+
end
3034
end

0 commit comments

Comments
 (0)