Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Sprockets from Rails

How do you remove Sprockets from Rails?

I've..

  • removed all the Sprockets Gems.
  • removed all the config.assets.* from initializers, etc..

Still, Rails is looking for Sprockets

/Users/username/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:105:in block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js (Sprockets::Railtie::ManifestNeededError)

......

 Example:
13:58:38 web.1  |   //= link_tree ../images
13:58:38 web.1  |   //= link_directory ../javascripts .js
13:58:38 web.1  |   //= link_directory ../stylesheets .css

How do you actually remove Sprockets?

like image 203
GN. Avatar asked Dec 28 '19 22:12

GN.


People also ask

What are rails Sprockets?

Sprockets is a Ruby library for compiling and serving web assets. Sprockets allows to organize an application's JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files.

What does rake assets Precompile do?

rake assets:precompile. We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.

What is asset pipeline rails?

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB. Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets.


1 Answers

To completely remove sprockets from a Rails project:

Remove:

# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'

from Gemfile then run bundle install.

Replace:

require 'rails/all'

with:

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"

in config/application.rb file.

Remove:

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# Suppress logger output for asset requests.
config.assets.quiet = true

from config/environments/development.rb file.

Remove:

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

from config/environments/production.rb file.

Remove config/initializers/assets.rb file.

You can also remove app/assets folder but it is not necessary because you may need it later if you changed your mind.

like image 184
MibraDev Avatar answered Oct 13 '22 00:10

MibraDev