Before we start the upgrade process for Webpacker 6, we are going to create a small demo application for us to work on.
If you are upgrading an existing app or not using this series as a tutorial, you can skip this step! We will begin the formal upgrade process in the next article.
Generate a new Rails app
First we will generate new Ruby on Rails app:
rails new webpacker_6 --skip-sprockets --skip-spring --skip-webpack-install --skip-bundle cd webpacker_6
--skip-sprockets: Skip Sprockets files
--skip-spring: Don’t install Spring application preloader
--skip-bundle: Don’t run bundle install
--skip-webpack-install: Don’t run Webpack install
Setup the Database
Turn off asset scaffolding
Prevent Rails from creating asset files when running the generators and scaffolds:
# config/application.rb # ... module Webpacker6 class Application < Rails::Application config.load_defaults 6.1 + config.generators do |g| + g.assets false + end end end
Add Pages Controller
Generate pages controller with a home action:
bin/rails g controller pages home
Add Root Route
pages#home as the root route:
# config/routes.rb Rails.application.routes.draw do get 'pages/home' + root to: 'pages#home' # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end
View All Articles
Note: Because we skipped the Webpacker install task, you will get an error if you try to start the application as is. We will fix that in the next article.