mipearson / webpack-rails-demo

Demo application for the webpack-rails gem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webpack-rails-demo

This repository demonstrates basic use of webpack-rails in a Rails 4.2 application.

Even though it demonstrates webpack-rails coexisting with sprockets, sprockets is not required or used by webpack-rails.

Usage

git clone https://github.com/mipearson/webpack-rails-demo.git
cd webpack-rails-demo
bundle install
npm install
foreman start

Then open localhost:3000 in your browser. If everything is working, you should see "Sprockets works!" and "Webpack works!"

Steps Taken

  1. Created new rails project: rails new --skip-keeps --skip-active-record --skip-spring --skip-turbolinks --skip-test-unit webpack-rails-demo
  2. Remove files, gems unnecessary for the demo
  3. Added webpack-rails to the Gemfile and ran bundle install
  4. Ran bundle exec rails generate webpack_rails:install
  5. Added controller, routes and views for "Welcome" page
  6. Added sprockets-based javascript for "Welcome" page
  7. Edited webpack/application.js
  8. Added *webpack_asset_paths to index.html.erb to load webpacked javascript
  9. Ran foreman start
  10. Opened localhost:3000, confirmed that both Sprockets & Webpack are loaded

About

Demo application for the webpack-rails gem

License:MIT License


Languages

Language:Ruby 72.7%Language:JavaScript 19.6%Language:CSS 4.8%Language:HTML 2.9%