Remove "assets" and "turbolinks" in "Rails6".

Purpose of this article

This article uses Webpacker with Rails 6 This is an article that records the procedure for deleting ʻassets pipeline and turbolinks`.

--Confirmation and review of development contents --Memorandum of development procedure ――If it helps other people even a little

I thought, and created this article.

Why did you decide to remove assets?

Starting with Rails6, Webpacker is used as the standard module bundler. Assets at the time of rails new are still alive, The javascript directory is no longer initially created in Rails 6 during the initial installation on assets. Also, sprockets gem updates have been delayed and the new JavaScript ES2015 While front-end frameworks such as React and Vue are becoming mainstream Break away from the dual system of assets and webpacker I wanted to experience development only with webpacker and ran it.

Development environment

This time, I am developing with Docker-compose of the article I wrote earlier.

Qiita article for details on environment construction

Manual for building a stable development environment for "Rails6" with "Docker-compose"

Please confirm.

1. Delete assets

In Rails 6 where Webpacker is standard, it is aggregated under app / javascript without using assets. I want to delete assets.

Delete the app / assets directory

2. Describe the reading in application.js

Load bootstrap as a front-end framework with jquery used in Ajax etc. Furthermore, by loading application.scss, js and css are centrally managed by webpacker.



import "../stylesheets/application.scss"

3. Create a stylesheets directory and application.scss file under the javascript directory

Describe the loading of bootstrap in application.scss.


@import "~bootstrap/scss/bootstrap";

4. Modify layouts.scss

Now that we no longer use assets, change layouts to stylesheet_pack_tag. Also, since turbo link is not used, it will be changed to the following code.


<%= stylesheet_pack_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application' %>

5. Remove turbolinks

In Rails 6, it seems that it can not be completely deleted unless it is deleted with both yarn and gem.

Delete with yarn

yarn remove turbolinks

Delete with Gemfile

gem 'turbolinks', '~> 5'
bundle install

Furthermore, delete "turbolinks" from app / javascript / packs / application.js.

6. Edit config / webpack / environment.js

In order to use $ in jQuery with Ajax, write the following.


const { environment } = require('@rails/webpacker')

const webpack = require('webpack')
    new webpack.ProvidePlugin({
        $: 'jquery/src/jquery',
        jQuery: 'jquery/src/jquery'

module.exports = environment

7. Edit webpacker.yml

Since I am using docker, I get an error on localhost. We will correct and respond to the following three locations.


check_yarn_integrity: false

8. Add port to docker-compose.yml

Add a port for the correction made in 8.

- "3035:3035"

9. Lower the version of sprockets

It seems that assets cannot be completely deleted without lowering the version of sprockets in Gemfile.

Modify gemfile

gem 'sprockets', '~> 3.7.2'
bundle update sprockets

10. Introduction of foreman

foreman is a tool that can read Procfiles and manage multiple processes. Describe the process managed by the application in Procfile It corresponds by placing it in the application root. Reference URL: foreman

gem 'foreman'

web: bundle exec rails s -b -p 3000
webpacker: bin/webpack-dev-server

Bundle install.

bundle install

The bash file has also been modified to match foreman.


rails_server() {
  compose_stop $app
  $dc run $rm --service-ports $app bundle exec foreman start -f

The above should complete the removal of ʻassets turbolinks`.


If possible, Ajax also wanted to break away from JQuery, Due to lack of learning, replacement has not been completed yet. Once you have completed your studies, you can say that you have finally moved to ES2015.

Because it is a beginner, there may be work contents and mistakes. We would appreciate it if you could let us know if you have any notices.

Recommended Posts

Remove "assets" and "turbolinks" in "Rails6".
Disable turbolinks in Rails
Enable jQuery and Bootstrap in Rails 6 (Rails 6)
CRUD features and MVC in Rails
Remove nil and blank string array in rails Array and display them concatenated
Rails and FormData
Group_by in Rails
(Basic authentication) environment variables in rails and Docker
[Rails] Ranking and pagination in order of likes
Rails valid? And invalid?
Model association in Rails
Adding columns in Rails
Change date and time to Japanese notation in Rails
CSRF measures in Rails
Calendar implementation and conditional branching in Rails Gem simple calendar
Use images in Rails
Understand migration in rails
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapters 4 and 5
Get location information in Rails and sort in ascending order
Split routes.rb in Rails6
Implement markdown in Rails
Differences between namespace, module, scope and as in Rails routing
[Rails] Introducing Travis CI and getting stuck in db: create
Implementation policy to dynamically save and display Timezone in Rails
Implement login function in Rails simply by name and password (1)
Implement login function in Rails simply by name and password (2)
Implement login function simply with name and password in Rails (3)
Implement user registration function and corporate registration function separately in Rails devise
[Rails] Find_each loops endlessly and eats up memory in production
Remove consecutive line breaks and tabs before and after in Java
Get UserAgent in [Rails] controller
Implement follow function in Rails
Rails: Difference between resources and resources
Rails Posts and User Linkage
[Rails] require method and permit method
Rails "render method" and "redirect method"
Rails Tutorial Records and Memorandum # 0
rails path and url methods
Mock and stub in RSpec
Implement LTI authentication in Rails
Rails is difficult and painful!
Error in rails db: migrate
Introducing Bootstrap and Font-Awesome (Rails)
Rails is difficult and painful! Ⅱ
Gem often used in Rails
Display Flash messages in Rails
[Rails] Add / Remove Forms (cocoon)
View monthly calendar in Rails
Implement import process in Rails
[Rails] How to disable turbolinks
[Rails] strftime this and that
Use multiple checkboxes in Rails6!
Rails web server and application server
Rewrite Routes in Rails Engine
Implemented hashtag search like Instagram and Twitter in Rails (no gem)
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
(Ruby on Rails6) Creating a database and displaying it in a view
[Rails] DB settings and operations (mysql), Rubocop in VSCode, useful extensions
How to delete large amounts of data in Rails and concerns
When log data accumulates in Rails and the environment stops working
Install Rails in the development environment and create a new application