Name: sinatra-asset-pipeline
Owner: Helium
Description: An asset pipeline implementation for Sinatra based on Sprockets.
Forked from: kalasjocke/sinatra-asset-pipeline
Created: 2016-11-16 23:08:09.0
Updated: 2016-11-16 23:08:10.0
Pushed: 2016-11-16 23:21:07.0
Size: 208
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
An asset pipeline implementation for Sinatra based on Sprockets. sinatra-asset-pipeline supports both compiling assets on the fly for development as well as precompiling assets for production. The design goal for sinatra-asset-pipeline is to provide good defaults for integrating your Sinatra application with Sprockets.
Install Sinatra Asset Pipeline from RubyGems:
install sinatra-asset-pipeline
Or, include it in your project's Gemfile
:
'sinatra-asset-pipeline', '~> 1.0'
Add the provided Rake tasks to your applications Rakefile
:
ire 'sinatra/asset_pipeline/task'
ire './app'
tra::AssetPipeline::Task.define! App
This makes your application serve assets inside assets
folder under the public /assets
path. You can use the helpers provided by sprocket-helpers inside your assets to ease locating your assets.
During deployment of your application you can use precompile
rake task to precompile your assets to serve them as static files from your applications public folder.
_ENV=production rake assets:precompile
To leverage the Sprockets preprocessor pipeline inside your app you can use the assets_js_compressor
and assets_css_compressor
settings respectively. See the Using Processors section of the Sprockets readme for details.
If your application runs Sinatra in classic style you can define your Rake tasks as follows:
tra::AssetPipeline::Task.define! Sinatra::Application
In its most simple form, you just register the Sinatra::AssetPipeline
Sinatra extension within your application:
ire 'sinatra/asset_pipeline'
s App < Sinatra::Base
gister Sinatra::AssetPipeline
t '/' do
'hi'
d
However, if your application doesn't follow the defaults you can customize it as follows:
ire 'sinatra/asset_pipeline'
s App < Sinatra::Base
Include these files when precompiling assets
t :assets_precompile, %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
The path to your assets
t :assets_paths, %w(assets)
Use another host for serving assets
t :assets_host, '<id>.cloudfront.net'
Which prefix to serve the assets under
t :assets_prefix, 'custom-prefix'
Serve assets using this protocol (http, :https, :relative)
t :assets_protocol, :http
CSS minification
t :assets_css_compressor, :sass
JavaScript minification
t :assets_js_compressor, :uglifier
Register the AssetPipeline extension, make sure this goes after all customization
gister Sinatra::AssetPipeline
t '/' do
'hi'
d