diff --git a/lib/propshaft/assembly.rb b/lib/propshaft/assembly.rb index 3fbb11c..7ca5b94 100644 --- a/lib/propshaft/assembly.rb +++ b/lib/propshaft/assembly.rb @@ -18,6 +18,10 @@ def load_path @load_path ||= Propshaft::LoadPath.new(config.paths, version: config.version) end + def application_stylesheets_load_path + @application_stylesheets_load_path ||= Propshaft::LoadPath.new([File.join(Rails.root, "app", "assets", "stylesheets")], version: config.version) + end + def resolver @resolver ||= if manifest_path.exist? Propshaft::Resolver::Static.new manifest_path: manifest_path, prefix: config.prefix diff --git a/lib/propshaft/helper.rb b/lib/propshaft/helper.rb index 66e8d25..34a69c1 100644 --- a/lib/propshaft/helper.rb +++ b/lib/propshaft/helper.rb @@ -7,15 +7,15 @@ def compute_asset_path(path, options = {}) # Add an option to call `stylesheet_link_tag` with `:all` to include every css file found on the load path. def stylesheet_link_tag(*sources, **options) if sources.first == :all - super(*all_stylesheets_paths, **options) + super(*all_application_stylesheets_paths, **options) else super end end - # Returns a sorted and unique array of logical paths for all stylesheets in the load path. - def all_stylesheets_paths - Rails.application.assets.load_path + # Returns a sorted and unique array of logical paths for all stylesheets only in the application stylesheets load path. + def all_application_stylesheets_paths + Rails.application.assets.application_stylesheets_load_path .assets(content_types: [ Mime::EXTENSION_LOOKUP["css"] ]) .collect { |css| css.logical_path.to_s } .sort diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index fb160a1..9a01256 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -31,5 +31,6 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") + config.assets.paths << File.join(Rails.root, "vendor", "stylesheets") end end diff --git a/test/dummy/vendor/stylesheets/library.css b/test/dummy/vendor/stylesheets/library.css new file mode 100644 index 0000000..e69de29 diff --git a/test/propshaft_integration_test.rb b/test/propshaft_integration_test.rb index 554303d..b5d3222 100644 --- a/test/propshaft_integration_test.rb +++ b/test/propshaft_integration_test.rb @@ -8,6 +8,7 @@ class PropshaftIntegrationTest < ActionDispatch::IntegrationTest assert_select 'link[href="/assets/hello_world-4137140a.css"][data-custom-attribute="true"]' assert_select 'link[href="/assets/goodbye-b1dc9940.css"][data-custom-attribute="true"]' + assert_select 'link[href="/assets/library-356a192b.css"][data-custom-attribute="true"]', 0 assert_select 'script[src="/assets/hello_world-888761f8.js"]' end