LoginSignup
8
8

More than 5 years have passed since last update.

EngineYard で動く Rails アプリで Bower を使う

Last updated at Posted at 2013-08-16

環境等

  • EngineYard (stable-v4)
  • Ruby 2.0.0
  • Rails 4.0
  • Bower 1.1.0

package.json

EngineYard は node.js アプリもサポートしているので、package.json があると自動的にそれに従ってインストールが走るようです。

package.json は RAILS_ROOT に置いておきます。

RAILS_ROOT/package.json
{
  "name": "app_name",
  "version": "0.0.1",
  "dependencies": {
    "bower": "1.1.0"
  }
}

たんに npm install をしているだけなので、通常と同じように RAILS_ROOT の node_modules ディレクトリにインストールされます。

deploy/before_compile_assets.rb

bower でのインストールは assets precompile の前までには終わらせておきたいので、EngineYard の deploy フックのうち、before_compile_assets というものを使います。

RAILS_ROOT/deploy/before_compile_assets.rb
run! './node_modules/.bin/bower install'

あとは .bowerrc / bower.json 等々に従ってよしなにやってくれるでしょう。

8
8
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8