1

I started a fresh rails 7 application using jsbundling-rails (with esbuild) and cssbundling-rails (with bootstrap).

The pipeline works well to build assets. After testing that, I removed sprockets gem and configs from application (basically, I removed all calls with .assets on config files)

So, after remove sprocket, my assets can't be reach from frontend <%= javascript_include_tag 'application' %>

I'm debugging but it isn't clear what's wrong...

1 Answer 1

0

After I've seen some tutorials, I discovered which sprockets can't be removed.

While I'm upgrading I removed a lot of gems, and someone that import sprockets as a dependency.

I fixed adding sprockets directly:

gem "sprockets-rails", :require => "sprockets/railtie"

I also simplified my assets.rb file:

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font")
Rails.application.config.assets.paths << Rails.root.join("node_modules/@fortawesome/fontawesome-free/webfonts")
Rails.application.config.assets.paths << Rails.root.join("node_modules/summernote/dist/font")
Rails.application.config.assets.paths << Rails.root.join("app/assets/fonts")

# Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

It's important search for other files which use .assets from code.

My manifest.js file (sprockets looks to that file):

//= link_tree ../images
//= link_tree ../builds

References:

https://www.youtube.com/watch?v=h8DmZhkRoJs

https://www.youtube.com/watch?v=DhM-Wh9Pmd4

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.