Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Webpacker 6: Tutorial Setup
Andrew Mason
Andrew Mason

Posted on • Edited on • Originally published atandrewm.codes

     

Webpacker 6: Tutorial Setup

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-bundlecdwebpacker_6
Enter fullscreen modeExit fullscreen mode
  • --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

bin/rails db:prepare
Enter fullscreen modeExit fullscreen mode

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  endend
Enter fullscreen modeExit fullscreen mode

Add Pages Controller

Generate pages controller with a home action:

bin/rails g controller pages home
Enter fullscreen modeExit fullscreen mode

Add Root Route

Setpages#home as the root route:

# config/routes.rbRails.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.htmlend
Enter fullscreen modeExit fullscreen mode

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.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
juanvqz profile image
Juan Vasquez
404 bio not found
  • Email
  • Location
    Oaxaca, México
  • Work
    Software Engineer
  • Joined

Hi!
why did you remove sprockets?
why is used for?

--skip-sprockets: Skip Sprockets files
Enter fullscreen modeExit fullscreen mode

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Andrew Mason is a full stack Ruby on Rails engineer and content creator in the Ruby community.
  • Location
    Phoenix, AZ
  • Education
    UNCW
  • Work
    Senior Product Engineer at Podia
  • Joined

More fromAndrew Mason

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp