Making a Rails engine is super easy and is the best way to package static assets for re-use across Rails apps.

Here are some tips to ensure your assets engine is as awesome as possible.

Use the app/ directory, not vendor/ or lib/

Rails picks up javascripts and stylesheets from all three of these directories, but only precompiles images from app/. Furthermore app/ is officially recommended by the Rails Guide. Stick your assets in app/assets/ and all your engine assets will Just Work, everywhere.

Configure the asset pipeline in your engine, if needed

If the readme for your engine asks the user to edit config/application.rb, create an initializer, or something similar, you’re probably doing it wrong. Your engine should specify nonstandard extensions and paths for your assets on behalf of your users. See for example how Zurb Foundation’s Engine class asks the asset pipeline to precompile assets in nonstandard paths.

Lock your engine version to that of the upstream assets version, if applicable

Don’t confuse your users by introducing yet another versioning scheme, instead simply follow the upstream versioning scheme of the assets you’re packaging. A good example of matching versioning is bootstrap-sass.

Name your engine “#{upstream_name}-rails”

Follow convention and make it easy to tell what your engine does by looking at the name.

Thanks for all the wonderful engines, Rails people! <3