简体   繁体   English

Spree -4.4 - 全新安装给出链轮错误 re: spree-dashboard.js

[英]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.我面临在新鲜的狂欢 4.4 上找不到的丢失的“spree-dashboard.js”文件。 Its not fixed by runing yarn install.它不是通过运行 yarn install 来修复的。

Check if you have one at app/javascript and copy it to app/assets/javascripts and see if it resolves.检查您是否在 app/javascript 中有一个并将其复制到 app/assets/javascripts 并查看它是否可以解决。

I found the file and just dropped it in one of the paths it was looking into.我找到了该文件,然后将其放到了它正在查找的路径之一中。

Install gem 'turbo-rails' instead of turbolinks安装 gem 'turbo-rails' 而不是 turbolinks

For Further Help Follow the link: How To Migrating From Turbolinks To Turbo https://www.honeybadger.io/blog/hb-turbolinks-to-turbo/如需进一步帮助,请点击链接:如何从 Turbolinks 迁移到 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. Spree 文档指导我们安装 esbuild。 But the documentation never explains how to actually use esbuild to build our JS.但是文档从未解释过如何实际使用 esbuild 来构建我们的 JS。

You normally have jsbundling-rails added in your Gemfile.lock.您通常会在 Gemfile.lock 中添加 jsbundling-rails。 You can find more info about that gem here: https://github.com/rails/jsbundling-rails您可以在此处找到有关该 gem 的更多信息: 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:要开始一个新的 Spree 项目,最好使用 esbuild 生成 rails 项目,这要归功于这个命令:

rails new myapp -j esbuild

That way the app will already be using esbuild which is the tech used by spree.这样,该应用程序将已经使用 esbuild,这是 spree 使用的技术。

Otherwise, you would have to migrate from webpacker to esbuild.否则,您将不得不从 webpacker 迁移到 esbuild。 I found a nice tuto here: https://dev.to/thomasvanholder/how-to-migrate-from-webpacker-to-jsbundling-rails-esbuild-5f2我在这里找到了一个不错的教程: 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:最后,要使用 esbuild 构建 JS,您可以将此行添加到 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.安装 esbuild 的时候一般会在终端打印出来,但是很容易漏掉。

And when you run yarn build this command will generate the proper spree-dashboard.js file within app/assets/builds.当您运行yarn build时,此命令将在 app/assets/builds 中生成正确的spree-dashboard.js文件。

Also, the esbuild install command adds a line in Procfile.dev with a "watch" option.此外,esbuild install 命令在 Procfile.dev 中添加了一行带有“watch”选项的行。 You'll eventually want to start the project using ./bin/dev which starts a Foreman process that handles what's in Procfile.dev.您最终会希望使用./bin/dev启动项目,它会启动一个处理 Procfile.dev 中内容的 Foreman 进程。

Finally, as a bonus, I also followed this nice tutorial: https://noelrappin.com/blog/2021/12/typescript-and-jsbundling-and-rails-7/最后,作为奖励,我还遵循了这个不错的教程: https ://noelrappin.com/blog/2021/12/typescript-and-jsbundling-and-rails-7/

Which helps you set up esbuild + jsbundling-rails + typescript.这可以帮助您设置 esbuild + jsbundling-rails + typescript。 If you like typescript, this is an easy way to use it with esbuild in a Rails project.如果你喜欢 typescript,这是在 Rails 项目中与 esbuild 一起使用的一种简单方法。

I faced the same issue, webpack was looking for "@spree/dashboard".我遇到了同样的问题,webpack 正在寻找“@spree/dashboard”。

The installation of that package solved the issue该软件包的安装解决了这个问题

yarn add @spree/dashboard

running the following command worked for me运行以下命令对我有用

yarn build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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