diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 4274366f1..9feed6587 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -5,6 +5,7 @@ default: &default source_entry_path: packs public_output_path: packs cache_path: tmp/cache/webpacker + custom_compile: false # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] diff --git a/lib/tasks/webpacker/check_binstubs.rake b/lib/tasks/webpacker/check_binstubs.rake index 47d368e4b..7344e8c34 100644 --- a/lib/tasks/webpacker/check_binstubs.rake +++ b/lib/tasks/webpacker/check_binstubs.rake @@ -1,7 +1,8 @@ namespace :webpacker do desc "Verifies that bin/webpack & bin/webpack-dev-server are present." task :check_binstubs do - unless File.exist?("bin/webpack") && File.exist?("bin/webpack-dev-server") + unless Webpacker.config.custom_compile? || + (File.exist?("bin/webpack") && File.exist?("bin/webpack-dev-server")) $stderr.puts "Webpack binstubs not found.\n"\ "Have you run rails webpacker:install ?\n"\ "Make sure the bin directory or binstubs are not included in .gitignore\n"\ diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index 748fe3982..958a6b405 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -17,6 +17,10 @@ def compile? fetch(:compile) end + def custom_compile? + fetch(:custom_compile) + end + def source_path root_path.join(fetch(:source_path)) end diff --git a/lib/webpacker/manifest.rb b/lib/webpacker/manifest.rb index 83d86ae1c..484d75545 100644 --- a/lib/webpacker/manifest.rb +++ b/lib/webpacker/manifest.rb @@ -42,7 +42,21 @@ def find(name) def handle_missing_entry(name) raise Webpacker::Manifest::MissingEntryError, - "Can't find #{name} in #{config.public_manifest_path}. Is webpack still compiling?" + "Can't find #{name} in #{config.public_manifest_path}. Manifest contains:\n#{JSON.pretty_generate(@data)}" + end + + def missing_file_from_manifest_error(bundle_name) + msg = <<-MSG +Webpacker can't find #{bundle_name} in #{config.public_manifest_path}. Possible causes: +1. You are hot reloading. +2. You want to set Configuration.compile to true for your environment. +3. Webpack has not re-run to reflect updates. +4. You have misconfigured Webpacker's config/webpacker.yml file. +5. Your Webpack configuration is not creating a manifest. +Your manifest contains: +#{@data.to_json} + MSG + raise(Webpacker::FileLoader::NotFoundError.new(msg)) end def data diff --git a/test/manifest_test.rb b/test/manifest_test.rb index c62a8df3a..758a92736 100644 --- a/test/manifest_test.rb +++ b/test/manifest_test.rb @@ -9,8 +9,17 @@ def test_lookup_exception error = assert_raises Webpacker::Manifest::MissingEntryError do Webpacker.manifest.lookup(asset_file) end + expected = <<-MSG.strip +Can't find calendar.js in #{manifest_path}. Manifest contains: +{ + "bootstrap.css": "/packs/bootstrap-c38deda30895059837cf.css", + "application.css": "/packs/application-dd6b1cd38bfa093df600.css", + "bootstrap.js": "/packs/bootstrap-300631c4f0e0f9c865bc.js", + "application.js": "/packs/application-k344a6d59eef8632c9d1.js" +} + MSG - assert_equal "Can't find #{asset_file} in #{manifest_path}. Is webpack still compiling?", error.message + assert_equal expected, error.message end end