Skip to content

Give your frontend code some respect in Rails! Don't even front.

License

Notifications You must be signed in to change notification settings

collinschaafsma/frontin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontin

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 public/.

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.

Learn more about grunt https://github.com/cowboy/grunt, and the backbone-boilerplate https://github.com/backbone-boilerplate/grunt-bbb

Build Status

Testing against: node 0.6, 0.7 / Ruby MRI 1.9.2, 1.9.3

Why

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.

Installation

Add this line to your application's Gemfile:

gem 'frontin'

And then execute:

$ bundle

Or install it yourself as:

$ gem install frontin

Dependencies

  • Ruby ~> 1.9.2
  • Node ~> 0.6

Usage

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 frontend/ directory. 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.

Greenfield project

rails new my_project -S

Existing project

config/application.rb

# comment out
require "sprockets/railtie"

# disable the asset pipeline
config.assets.enabled = false

# optionally disable the generators
config.generators.stylesheets = false
config.generators.javascripts = false

Example Rails app

https://github.com/collinschaafsma/frontin_rails_example

Thanks

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Give your frontend code some respect in Rails! Don't even front.

Resources

License

Stars

Watchers

Forks

Packages

No packages published