jacobmischka / gatsby-plugin-react-svg

Adds svg-react-loader to gatsby webpack config
https://www.npmjs.com/package/gatsby-plugin-react-svg
MIT License
70 stars 21 forks source link

Unable to resolve svg path in deploy(Netlify) but works in localhost #46

Closed thanigai1709 closed 2 years ago

thanigai1709 commented 2 years ago

5:48:09 PM: failed Building production JavaScript and CSS bundles - 21.814s 5:48:09 PM: error Generating JavaScript bundles failed 5:48:09 PM: Can't resolve '../icons/coderapper.svg' in '/opt/build/repo/src/pages' 5:48:09 PM: If you're trying to use a package make sure that '../icons/coderapper.svg' is installed. If you're trying to use a local file make sure that the path is correct. 5:48:09 PM: error Generating JavaScript bundles failed 5:48:09 PM: Can't resolve '../icons/tarkalabs.svg' in '/opt/build/repo/src/pages' 5:48:09 PM: If you're trying to use a package make sure that '../icons/tarkalabs.svg' is installed. If you're trying to use a local file make sure that the path is correct. 5:48:09 PM: error Generating JavaScript bundles failed 5:48:09 PM: Can't resolve '../icons/railsfactory.svg' in '/opt/build/repo/src/pages' 5:48:09 PM: If you're trying to use a package make sure that '../icons/railsfactory.svg' is installed. If you're trying to use a local file make sure that the path is correct. 5:48:09 PM: error Generating JavaScript bundles failed 5:48:09 PM: Can't resolve '../icons/eam360.svg' in '/opt/build/repo/src/pages' 5:48:09 PM: If you're trying to use a package make sure that '../icons/eam360.svg' is installed. If you're trying to use a local file make sure that the path is correct. 5:48:10 PM: ​ 5:48:10 PM: ──────────────────────────────────────────────────────────────── 5:48:10 PM: "build.command" failed
5:48:10 PM: ──────────────────────────────────────────────────────────────── 5:48:10 PM: ​ 5:48:10 PM: Error message 5:48:10 PM: Command failed with exit code 1: npm run build 5:48:10 PM: ​ 5:48:10 PM: Error location 5:48:10 PM: In Build command from Netlify app: 5:48:10 PM: npm run build 5:48:10 PM: ​ 5:48:10 PM: Resolved config 5:48:10 PM: build: 5:48:10 PM: command: npm run build 5:48:10 PM: commandOrigin: ui 5:48:10 PM: publish: /opt/build/repo/public 5:48:10 PM: publishOrigin: ui 5:48:10 PM: plugins: 5:48:10 PM: - inputs: {} 5:48:10 PM: origin: ui 5:48:10 PM: package: '@netlify/plugin-gatsby' 5:48:10 PM: redirects: 5:48:10 PM: - from: /api/* status: 200 to: /.netlify/functions/gatsbyCaching artifacts 5:48:10 PM: Started saving node modules 5:48:10 PM: Finished saving node modules 5:48:10 PM: Started saving build plugins 5:48:10 PM: Finished saving build plugins 5:48:10 PM: Started saving pip cache 5:48:10 PM: Finished saving pip cache 5:48:10 PM: Started saving emacs cask dependencies 5:48:10 PM: Finished saving emacs cask dependencies 5:48:10 PM: Started saving maven dependencies 5:48:10 PM: Finished saving maven dependencies 5:48:10 PM: Started saving boot dependencies 5:48:10 PM: Finished saving boot dependencies 5:48:10 PM: Started saving rust rustup cache 5:48:10 PM: Finished saving rust rustup cache 5:48:10 PM: Started saving go dependencies 5:48:10 PM: Finished saving go dependencies 5:48:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2 5:48:10 PM: Creating deploy upload records 5:48:10 PM: Failing build: Failed to build site 5:48:10 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 5:48:10 PM: Finished processing build request in 1m10.645108901s

import CoderapperIcon from "../icons/coderapper.svg"; import TarkalabsIcon from "../icons/tarkalabs.svg"; import RailsfactoryIcon from "../icons/railsfactory.svg"; import Eam360Icon from "../icons/eam360.svg";

plugins: [ gatsby-plugin-react-helmet, "gatsby-plugin-sass", gatsby-plugin-image, gatsby-plugin-sharp, gatsby-transformer-sharp, { resolve: "gatsby-plugin-react-svg", options: { rule: { include: /icons/, }, }, }, ],

jacobmischka commented 2 years ago

As the error message suggests, make sure the path is correct. Looks like others have been confused in the past about incorrect case-sensitive paths working on Windows but not Linux: https://spectrum.chat/gatsby-js/general/netlify-deploy-is-failing-but-my-gatsby-site-builds-and-serves-fine-localy~2b2ecabe-2221-46cd-b8e4-1f711034a3ab

In any event, I don't think this plugin is at fault.