Here we will guide you through the process of adding Proscenium to an existing Rails 7 app, and demonstrate how simple and easy it is to use, especially when you side load your client side code.
There is absolutely nothing else that you need to install or configure to get started with Proscenium. It is a Ruby gem, and it will work with any version of Rails 7 or higher.
- Replace
sprockets-rails
withproscenium
in your Gemfile. - Remove all
config.assets.*
settings from yourconfig/environments/*
files. - Delete
app/assets/config/manifest.js
. - Delete the
config/initializers/assets.rb
file. - Replace all asset_helpers (
image_url
,font_url
) in css files with standardurl()
s. - If you are importing only the frameworks you need (instead of
rails/all
), removerequire "sprockets/railtie"
from yourconfig/application.rb
file. - Update calls to
stylesheet_link_tag
andjavascript_include_tag
with full paths to your CSS and JS assets. - Remove all sprockets directives, and replace with import statements.
Proscenium does not rely on asset_helpers (asset_path
, asset_url
, image_url
, etc.) like Sprockets did. Instead, you simply use the standard url()
function in your css files, and use absolute or relative URL's.
- background: image_url('hero.jpg');
+ background: url('/hero.jpg');
Sprockets required all your assets be loacted in the app/assets
directory, and calls to the stylesheet_link_tag
and javascript_include_tag
helpers would automatically prepend the app/assets
path to the asset name. Proscenium does not do this, because assets can be located anywhere. So you must provide the absolute path to your assets.
- <%= stylesheet_link_tag "application" %>
+ <%= stylesheet_link_tag "/app/assets/stylesheets/application" %>
If you are using sprockets directives such as //= require jquery
, //= require_tree .
, etc., you will need to replace these with standard import
statements in JavaScript, and @import
at-rules in your CSS.
- //= require jquery
+ import 'jquery'
- /* require bootstrap */
+ @import url('bootstrap')
The recommended next step is to side load your JS and CSS assets.