Search code examples
ruby-on-railswebpacker

Dropping Webpacker from Rails 6. Now asset compilation doesn't work


ruby '3.0.1' 'rails', '~> 6.1.2'

I am dropping Webpacker from a rails project. I assume it was originally created using rails new with the webpacker flag to generate it but I do not know for sure. All I've done so far was remove yarn, browersify, babel, and etc source files and then moved all of my javascripts and stylesheets to app/assets and app/vendor.

I also added this to application.html.erb:

    <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => "reload" %>
    <%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %>

For a while, things were working. I was correcting paths, fixing small errors, and etc. Then after I restarted the server once, I was given a new error and now I'm stuck.

Sprockets::Rails::Helper::AssetNotPrecompiled in Universes#index

Showing /var/app/app/views/layouts/application.html.erb where line #8 raised:

application.css

Here's what I know so far:

  • I don't use an application.css. I have a app/assets/stylesheets/application.scss instead.
  • If I remove the stylesheet stylesheet_link_tag call, I get a similar one for application.js.
  • I'm sure I have the sass-rails gem installed so it should be using application.scss instead.
  • I've never used the base rails asset pipeline before. Only the webpacker-way of doing things. So I can assume very basic things are missing.

Any help would be appreciated. Thank you.


Solution

  • Lam Phan had what I needed. My assets/config/manifest.js was not configured correctly. I restored it to:

    //= link_tree ../images
    //= link_directory ../javascripts .js
    //= link_directory ../stylesheets .css
    

    and then made sure application.scss and application.js were at those paths. It was all easy after that. Thank you very much for your time.