Jason Swett Jason Swett - 5 months ago 59
AngularJS Question

Include stylesheets using browserify-rails

I'm using browserify-rails to include Angular UI Grid in my Rails project. My

application.coffee
contains the following:

require('angular-ui-grid')


This works in the sense that includes
node_modules/angular-ui-grid/ui-grid.js
, but it doesn't handle any of the stylesheets.

How can I get Angular UI Grid's stylesheets into my application as well?

Answer

The JavaScript includes and CSS includes are handled separately.

Your require('angular-ui-grid') call above handles the JS side of things since it's in the application.coffee manifest file.

To include the stylesheets, you'll need an additional require in the application.scss (or whichever file is your main CSS manifest).

browserify-rails does not include the node_modules directory in its asset load paths by default, so you have to add it inside the assets.rb file like this

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << "node_modules"