Give your frontend code some respect in Rails. Don't even front.
Frontin adds middleware to allow you to develop your frontend code in
Rails/root/frontend and serve it in development mode.
Frontin takes any request for
assets/**js, assets/**css or
app/**js and maps those requests to
Rails/root/frontend in development mode.
It also provides generators to easily setup the backbone-boilerplate using grunt so that you can easily build to
public/assets/ for production. Keeping your frontend source out of
Frontin is NOT designed to work with the asset pipeline. If that sounds pretty awesome to you, and you don't want your frontend code to get all mixed up in the Rails framework then frontin might be the kitties pj's for you.
Testing against: node 0.6, 0.7 / Ruby MRI 1.9.2, 1.9.3
Frontin was developed out of frustration with the asset pipeline. Instead it uses grunt to compile frontend code to the
public/ directory where a web server like
nginx can make quick work out of it. Grunt gives you all the controll in the world over building your frontend code. We feel it's the right tool for the job and prefer to
use the Rails framework for what it's best at.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install frontin
- Ruby ~> 1.9.2
- Node ~> 0.6
Frontin provides several generators to make life easy.
rails g frontin:install
This adds the
frontend/ directory to the root of your Rails project where you can start writing your frontend code.
In addition the node npm package grunt will be installed for building your assets with a sensible config.
To get started with
grunt checkout the docs. https://github.com/cowboy/grunt
Note: If grunt is not installed it will install grunt globally.
Frontin also makes it easy to install the backbone-boilerplate into your
frontend directory using
the node npm package
bbb. If your looking to build your frontend on Backbone we highly suggest you give the backbone-boilerplate a spin.
rails g frontin:bbb
To get started with the bbb grunt plugin checkout the docs. https://github.com/backbone-boilerplate/grunt-bbb
Be sure you run your
bbb commands in the root of the
Note: If bbb is not installed it will install bbb globally.
Disabling the asset pipeline
It's highly recommended that if you use frontin to disable the asset pipeline to avoid any conflicts. Besides, at this point you don't need it anymore, grunt or the bbb grunt plugin will take it from here.
rails new my_project -S
Example Rails app
- cowboy (Ben Alman) for writing grunt. https://github.com/cowboy/grunt
- tbranyen (Tim Branyen) for writing backbone-boilerplate. https://github.com/backbone-boilerplate/grunt-bbb
- wookiehangover (Sam Breed) and nicovalencia (Nico Valencia) for their inspiration and smarts
- All the other contributers to the projects that make frontin possible
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request