Webpacker: How to disable/remove webpacker from a project?

Created on 11 Mar 2018  Â·  4Comments  Â·  Source: rails/webpacker

I tried webpacker in a project, and now I want to disable or remove the webpacker from it decently, but I failed to find how to in Docs and searching, and also there isn't a Rake task defined for this.

So some help will be appreciated.

Most helpful comment

Updated:

Sometimes, you will need to disable things in order to successfully debug or test other things.

Disabling webpacker

  1. Comment out webpacker from Gemfile.
#gem 'webpacker'

Remember to run bundle install

  1. Comment out the single line on production and development.rb on the integrity check.

app/config/development.rb

#  config.webpacker.check_yarn_integrity = false

app/config/production.rb

#  config.webpacker.check_yarn_integrity = false
  1. Comment out any javascript_pack_tag or stylesheet_pack_tag

app/views/*

<%# javascript_pack_tag "" %>
<%# stylesheet_pack_tag "" %>
  1. Comment out any additional custom scripts/code/task that uses Webpacker

Update1: *I’m typing this on a phone and no access to laptop till night time. Will provide code snippet when I’m back

Feel free to add to the comments if I miss out anything.

All 4 comments

Updated:

Sometimes, you will need to disable things in order to successfully debug or test other things.

Disabling webpacker

  1. Comment out webpacker from Gemfile.
#gem 'webpacker'

Remember to run bundle install

  1. Comment out the single line on production and development.rb on the integrity check.

app/config/development.rb

#  config.webpacker.check_yarn_integrity = false

app/config/production.rb

#  config.webpacker.check_yarn_integrity = false
  1. Comment out any javascript_pack_tag or stylesheet_pack_tag

app/views/*

<%# javascript_pack_tag "" %>
<%# stylesheet_pack_tag "" %>
  1. Comment out any additional custom scripts/code/task that uses Webpacker

Update1: *I’m typing this on a phone and no access to laptop till night time. Will provide code snippet when I’m back

Feel free to add to the comments if I miss out anything.

@ytbryan Thanks for your rapid helping~

I commented out these lines, and the webpacker did not run compiling again when I run rails assets:precompile. But I found Rails still execute yarn install.

I'm not clear that if it's a feature of Rails 5 or because that webpacker hooks up a new webpacker:compile task to assets:precompile as documented here. If it was because of the later, how do I unhook it?

Thanks again ~

🤔 to give you an accurate answer, I need to trace the source code when I get back.

But at the back of my mind, I think you can:

  1. Run ‘bundle exec gem uninstall webpacker’
  2. And/or comment out the ‘.bin/yarn’ binstub

@ytbryan yes, it works. Thanks again~

Was this page helpful?
0 / 5 - 0 ratings