kalasjocke/sinatra-asset-pipeline
소개
Sprockets를 기반으로 한 Sinatra용 에셋 파이프라인입니다.
기타 프로젝트측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalSinatra Asset Pipeline 
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.
Installation
Install Sinatra Asset Pipeline from RubyGems:
gem install sinatra-asset-pipeline
Or, include it in your project's Gemfile:
gem 'sinatra-asset-pipeline', '~> 2.2.0'
Usage
Add the provided Rake tasks to your applications Rakefile:
require 'sinatra/asset_pipeline/task'
require './app'
Sinatra::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.
RACK_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.
Classic style
If your application runs Sinatra in classic style you can define your Rake tasks as follows:
Sinatra::AssetPipeline::Task.define! Sinatra::Application
Customization
In its most simple form, you just register the Sinatra::AssetPipeline Sinatra extension within your application:
require 'sinatra/asset_pipeline'
class App < Sinatra::Base
register Sinatra::AssetPipeline
get '/' do
'hi'
end
end
However, if your application doesn't follow the defaults you can customize it as follows:
require 'sinatra/asset_pipeline'
class App < Sinatra::Base
# Include these files when precompiling assets
set :assets_precompile, %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
# The path to your assets
set :assets_paths, %w(assets)
# Use another host for serving assets
set :assets_host, '<id>.cloudfront.net'
# Which prefix to serve the assets under
set :assets_prefix, 'custom-prefix'
# Serve assets using this protocol (http, :https, :relative)
set :assets_protocol, :http
# CSS minification
set :assets_css_compressor, :sass
# JavaScript minification
set :assets_js_compressor, :uglifier
# Register the AssetPipeline extension, make sure this goes after all customization
register Sinatra::AssetPipeline
# If you need more environments
set :precompiled_environments, %i(staging uat production)
get '/' do
'hi'
end
end
관련 프로젝트 살펴보기
불러오는 중…