Created
December 8, 2013 08:41
-
-
Save gnue/7854696 to your computer and use it in GitHub Desktop.
Bower でインストールしたコンポーネントを Padrino で参照できるようにしてみた(要 gem 'sprockets')
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rackup | |
# encoding: utf-8 | |
# This file can be used to start Padrino, | |
# just execute it from the command line. | |
require File.expand_path("../config/boot.rb", __FILE__) | |
# Bower components を /assets/* で参照できるようにする | |
if File.exists?('.bowerrc') | |
bowerrc = JSON.load(File.open('.bowerrc')) | |
assets_root = bowerrc['directory'] | |
assets = Dir[File.join(assets_root, '*')].collect { |path| | |
dist = File.join(path, 'dist') | |
path = dist if Dir.exists?(dist) | |
path | |
} | |
map '/assets' do | |
environment = Sprockets::Environment.new | |
assets.each { |path| environment.append_path path } | |
run environment | |
end | |
end | |
run Padrino.application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment