Rake Tasks
Propshaft provides several Rake tasks for managing your assets, available under the assets: namespace.
assets:precompile
Compiles and processes all assets from the configured load paths.
rails assets:precompile
Description: This is the primary task for production deployments. It performs the following actions:
- Finds all assets in
config.assets.paths. - Runs them through any configured compilers (e.g., to rewrite CSS
url()s). - Calculates a digest hash for each asset's content.
- Writes the digested assets to the
config.assets.output_path(usuallypublic/assets). - Creates a
.manifest.jsonfile that maps logical asset paths to their digested filenames.
When running this task in the development environment, Propshaft will print a warning because the presence of the manifest file will cause Rails to serve the static, compiled assets instead of dynamic ones.
assets:clobber
Removes the entire asset output directory.
rails assets:clobber
Description: This task deletes the directory specified by config.assets.output_path (e.g., public/assets). It's useful for ensuring a clean slate before a fresh precompilation.
assets:clean
Removes old, unreferenced compiled assets.
rails assets:clean[count]
Description: After multiple deployments, your output directory may contain old versions of assets that are no longer referenced in the manifest. This task removes those old files to save disk space.
count(optional, default: 2): The number of old versions of an asset to keep.
The task also keeps all assets younger than one hour, regardless of the count.
assets:reveal
Lists all the assets available in the load paths.
rails assets:reveal
Description: This task prints a list of all logical asset paths that Propshaft can find. It's a useful debugging tool to verify that your asset paths are configured correctly and that Propshaft is discovering your files as expected.
assets:reveal:full
Lists the full, absolute file system paths of all available assets.
rails assets:reveal:full
Description: Similar to assets:reveal, but it prints the full path to the source file on disk for each asset. This helps identify which specific file is being used when multiple assets have the same logical path.