question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cypress-component-configuration: mount issues with SVGs served with SVGR

See original GitHub issue

Current Behavior

I’ve got an NX monorepo which serves SVGs via svgr. nx serve works as expected, and all assets are rendered.

However, when I attempt to mount the app for Cypress component testing (configuration generated via nx generate cypress-component-configuration), I’m seeing the following error:

Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

I suspect that some of the settings in next.config.js are not being used when generating the configuration for Cypress component testing

Expected Behavior

Components can be mounted in the Cypress spec, just as they are rendered via nx serve

Steps to Reproduce

Minimal GitHub repro: https://github.com/liambutler/cypress-ct-nx-issue/

Instructions are in the readme

Failure Logs

webpack 5.74.0 compiled with 1 error in 29 ms
7 assets
55 modules

ERROR in ../../libs/ui/src/icon/assets/Achievements/one.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
| <circle cx="32" cy="32" r="32" fill="#DFE2E4"/>
| <path fill-rule="evenodd" clip-rule="evenodd" d="M35 21H31V42H35V31.5L40.0092 42.0018L44 42L39.0335 31.5L44 21H40.0092L35 31.5V21Z" fill="#394754"/>

webpack 5.74.0 compiled with 1 error in 31 ms

Environment

   Node : 16.16.0
   OS   : darwin arm64
   yarn : 1.22.19

   nx : 14.5.10
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.5.10
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.5.10
   @nrwl/eslint-plugin-nx : 14.5.10
   @nrwl/express : Not Found
   @nrwl/jest : 14.5.10
   @nrwl/js : 14.5.10
   @nrwl/linter : 14.5.10
   @nrwl/nest : Not Found
   @nrwl/next : 14.5.10
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.5.10
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.5.10
   @nrwl/web : 14.5.10
   @nrwl/workspace : 14.5.10
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
liambutlercommented, Aug 30, 2022

Makes sense, seeing as it’s in alpha. I’ll give your suggestion a try. Thanks!

0reactions
barbados-clemenscommented, Sep 6, 2022

Just add anything extra to that example repo and I’ll make sure to test against so it’ll work out of the box for you. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

ID collisions with multiple SVG · Issue #150 · gregberge/svgr
With React + Webpack when I load multiple SVG in the same component (SVG is in the dom), ids are the same in...
Read more >
Webpack - SVGR
SVGR provides an official webpack.js loader to import SVG as React ... It allows you to safely import SVG into your .css or...
Read more >
Using inline SVGs in Vue components - Caleb Porzio
Hoping for some instructions in the README, like npm install steves-pretty-icons , I see it's just a folder called svg with a bunch...
Read more >
How to Import SVGs in a React and Vite app - freeCodeCamp
Importing SVGs using the image tag is one of the easiest ways to use an SVG. If you initialize your app using CRA...
Read more >
How to use SVGs in React | Sanity.io guide
There are a few ways to use an SVG in a React app: Use it as a regular image; Import it as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found