From e3dde8a86e29f52650a3257a7b4488e9f6ba4241 Mon Sep 17 00:00:00 2001 From: Anthony Petruzzi Date: Sun, 18 May 2025 20:03:53 -0400 Subject: [PATCH] Update README.md Add example of adding a a custom assets path to propshaft --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6ea5226..de57c860 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ With Rails 8, Propshaft is the default asset pipeline for new applications. With ## Usage -Propshaft makes all the assets from all the paths it's been configured with through `config.assets.paths` available for serving and will copy all of them into `public/assets` when precompiling. This is unlike Sprockets, which did not copy over assets that hadn't been explicitly included in one of the bundled assets. +Propshaft makes all the assets from all the paths it's been configured with through `config.assets.paths` available for serving and will copy all of them into `public/assets` when precompiling. This is unlike Sprockets, which did not copy over assets that hadn't been explicitly included in one of the bundled assets. As an example, supposed you are vendoring libraries into a custom components path under the "vendor/assets" directory, thus the full directory is "vendor/assets/components". In order for Propshaft to use the libraries in this path you would have to add the following in your config/application.rb: + +```config.assets.paths << Rails.root.join("vendor", "assets", "components")``` You can however exempt directories that have been added through the `config.assets.excluded_paths`. This is useful if you're for example using `app/assets/stylesheets` exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like `Rails.root.join("app/assets/stylesheets")`).