简体   繁体   English

Gatsby JS Build 带有断开的链接

[英]Gatsby JS Build with broken links

Hi Guys so im new to this whole gatsby JS.嗨,伙计们,我对整个 gatsby JS 都是新手。 Loving it so far.爱到现在。 I have loaded some images through webpack and some external javascript via gatsby helmet.我通过 gatsby 头盔通过 webpack 和一些外部 javascript 加载了一些图像。 Everything works perfectly on development.一切都在开发中完美运行。

But when I take build the images and the scripts are all broken.但是当我构建图像时,脚本都被破坏了。 Console says its a 404.控制台说它是 404。

This is how I'm importing-  import heroImg from "../images/tiger.svg"

And this is how I call -  <img src={heroImg} alt="logo" className="img-responsive" />

Similarly for JS <script src={withPrefix('../static/gsap.js')} type="text/javascript" />同样对于 JS <script src={withPrefix('../static/gsap.js')} type="text/javascript" />

Everything is broken in build.一切都在构建中被破坏。 but working in development.但在开发中工作。

One thing I found in the build is when i remove the "../" in the url in the developer console the images are showing up.我在构建中发现的一件事是,当我在开发人员控制台中删除 url 中的“../”时,图像就会显示出来。 So i assume its some path issue while taking build.所以我假设它在构建时存在一些路径问题。 How do i solve this?我该如何解决这个问题? Please help请帮忙

I found a fix for this by adding path prefix in gatsby.我通过在 gatsby 中添加路径前缀找到了解决此问题的方法。

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

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