With the release of Sprockets 4, it apparently requires me to have an app/assets/config/manifest.js, which I shouldn't need since I'm using webpacker. However, when I updated my application.rb to exclude the sprockets import, the rails webpacker:compile task no longer worked.
What is the recommended method to disable sprockets and use webpacker alone? I'm kind of confused on what I need to do, since excluding the sprockets require caused errors in the webpacker:compile task.
Also, is simply converting all of my JS and CSS assets to webpacker and removeing app/assets enough to no longer need sprockets, or is sprockets involved in the use of webpacker or of regular rails views?
As a note, this app was originally on sprockets, and I converted it to webpacker a while back. There is a chance I may not have properly converted fully away from sprockets, but things have been working fine so far. Is there a guide on fully converting from sprockets to webpacker and removing sprockets from the app?
the rails webpacker:compile task no longer worked.
In order to help debug, could you please post as much as you can of:
./package.json./config/webpack/environment.js./config/webpacker.yml./app/javascript/packs/application.js Hmm. After looking at the error again, it seems that it was because I had some lines in my rails config/environments/*.rb files setting elements in config.assets, which apparently isn't defined without sprockets pulled in.
I seem to have things working now. However, it would be good to know where I can find a guide on fully converting from sprockets to webpacker. This need to remove the config lines and update the require statements in application.rb was not something I was aware of until I started having these errors, and it might have been nice to have a proper guide on the conversion.
Maybe you could have a link or section in your documentation on how to do a full conversion of an existing app from sprockets to webpacker? Having something like that would probably have helped me avoid this issue in the first place. If you have a link or section for that in your documentation, I must have missed it somehow, but searching in your readme for "sprockets" didn't find any mentions of how to convert an app.
I think https://github.com/rails/webpacker#usage has good content.
it would be good to know where I can find a guide on fully converting from sprockets to webpacker.
There are many detailed ones medium.com. When _I_ switched, I just did config.assets.enabled = false.
Maybe you could have a link or section in your documentation on how to do a full conversion of an existing app from sprockets to webpacker?
If you find or create a good one, feel free to create a PR.
I struggled to find high quality content on removing Sprockets fully, too. What I did was rails new my-app --skip-sprockets and see what the differences were.
Your first hunch seemed right:
/javascripts/packs)require 'sprockets/engine' import in application.rbSo:
Also, is simply converting all of my JS and CSS assets to webpacker and removeing app/assets enough to no longer need sprockets
yes
I just ran into this error with a new disabled-sprockets rails app, just because a style-library gem existed in the Gemfile (material-sass/bootstrap), even though the asset-pipeline was disabled.
This makes sense, since libraries should be added through npm/yarn versus the gemfile, but is the asset error considered normal behavior in this scenario? It feels a bit misleading because it's coming from a 3rd party asset source.
I created a new app with the --skip-sprockets flag and im still getting sprockets and sprockets-sass in my gemfile.lock. The only dependency is rails and i have removed the rails/all and replaced with each individual framework (not sprockets) any reason why im still getting sprockets?
I just tested @MutableLoss's angle and found that the presence of sassc-rails in my Gemfile was causing the issue. Apparently these gems kick off some sprockets activity of their own, in order to plug themselves in.
Most helpful comment
Hmm. After looking at the error again, it seems that it was because I had some lines in my rails
config/environments/*.rbfiles setting elements inconfig.assets, which apparently isn't defined without sprockets pulled in.I seem to have things working now. However, it would be good to know where I can find a guide on fully converting from sprockets to webpacker. This need to remove the config lines and update the require statements in
application.rbwas not something I was aware of until I started having these errors, and it might have been nice to have a proper guide on the conversion.Maybe you could have a link or section in your documentation on how to do a full conversion of an existing app from sprockets to webpacker? Having something like that would probably have helped me avoid this issue in the first place. If you have a link or section for that in your documentation, I must have missed it somehow, but searching in your readme for "sprockets" didn't find any mentions of how to convert an app.