Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 6 - How to use the old sprocket assets pipeline instead of webpacker?

Does anyone know if its possible to use the old sprocket pipeline setup in Rails 6? I've read somewhere that it's possible to use it instead of the new webpacker pipeline, but i can't find the source where i've read that.

Thanks in advance everyone!

Greetings!

like image 608
Prometheus Avatar asked Dec 22 '22 19:12

Prometheus


1 Answers

Well this is how i did it

rails new app-name --skip-webpack-install --skip-javascript

--skip-webpack-install prevents the generator from running rails webpacker:install.

--skip-javascript drops the webpacker gem from the Gemfile.

now in rails 6 app/assets/javascripts doesn't exists so you will have to create it yourself

Then, create app/assets/javascripts/application.js and add the following lines to it

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

Next, open app/assets/config/manifest.js and add the following line in the end

//= link_directory ../javascripts .js

Finally, open your application layout (app/views/layouts/application.html.erb) remove the javascript_pack_tag and add the following line

<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
like image 79
RazaUsman_k Avatar answered Mar 08 '23 23:03

RazaUsman_k