简体   繁体   中英

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.

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.

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/

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.

I faced the same issue, webpack was looking for "@spree/dashboard".

The installation of that package solved the issue

yarn add @spree/dashboard

running the following command worked for me

yarn build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM