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.
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!"
- Created new rails project:
rails new --skip-keeps --skip-active-record --skip-spring --skip-turbolinks --skip-test-unit webpack-rails-demo
- Remove files, gems unnecessary for the demo
- Added
webpack-rails
to theGemfile
and ranbundle install
- Ran
bundle exec rails generate webpack_rails:install
- Added controller, routes and views for "Welcome" page
- Added sprockets-based javascript for "Welcome" page
- Edited
webpack/application.js
- Added
*webpack_asset_paths
toindex.html.erb
to load webpacked javascript - Ran
foreman start
- Opened localhost:3000, confirmed that both Sprockets & Webpack are loaded