'Spree -4.4 - Fresh install gives sprocket error re: spree-dashboard.js
Im facing missing 'spree-dashboard.js' file not found on fresh spree 4.4. Its not fixed by runing yarn install.
Solution 1:[1]
Check if you have one at app/javascript and copy it to app/assets/javascripts and see if it resolves.
I found the file and just dropped it in one of the paths it was looking into.
Solution 2:[2]
Install gem 'turbo-rails' instead of turbolinks
For Further Help Follow the link: How To Migrating From Turbolinks To Turbo https://www.honeybadger.io/blog/hb-turbolinks-to-turbo/
Solution 3:[3]
I faced the same issue and found the solution. The Spree documentation guides us to install esbuild. But the documentation never explains how to actually use esbuild to build our JS.
You normally have jsbundling-rails added in your Gemfile.lock. You can find more info about that gem here: https://github.com/rails/jsbundling-rails
To start a new Spree project, it is best to generate the rails project using esbuild, thanks to this command:
rails new myapp -j esbuild
That way the app will already be using esbuild which is the tech used by spree.
Otherwise, you would have to migrate from webpacker to esbuild. I found a nice tuto here: https://dev.to/thomasvanholder/how-to-migrate-from-webpacker-to-jsbundling-rails-esbuild-5f2
And finally, to build JS with esbuild, you can add this line to your "scripts" in package.json:
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds"
It is normally printed in the terminal when you install esbuild, but you may easily miss it.
And when you run yarn build
this command will generate the proper spree-dashboard.js
file within app/assets/builds.
Also, the esbuild install command adds a line in Procfile.dev with a "watch" option. You'll eventually want to start the project using ./bin/dev
which starts a Foreman process that handles what's in Procfile.dev.
Finally, as a bonus, I also followed this nice tutorial: https://noelrappin.com/blog/2021/12/typescript-and-jsbundling-and-rails-7/
Which helps you set up esbuild + jsbundling-rails + typescript. If you like typescript, this is an easy way to use it with esbuild in a Rails project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | kevin Mucheru |
Solution 2 | Ashish Khetarpal |
Solution 3 | Kulgar |