Skip to content

"Could not locate module" error when using SVG from sprite as component #2685

@HumayraHanif

Description

@HumayraHanif

Version

3.0.4

Node and OS info

Node v8.9.1, npm 5.5.1, win 10

Steps to reproduce

  1. Within a project, add a SVG within a sprite by using "import Close from '@/assets/icons/ui.svg?close' "
  2. Add a unit test (using jest) to this component.
  3. Run tests.

What is expected?

Test runs

What is actually happening?

Get error:
Configuration error:

Could not lo

cate module @/assets/icons/ui.svg?close mapped as:
C:\Users\user\git\vue 3\proj\src\assets/icons/ui.svg?close.

Please check your configuration for these entries:
{
  "moduleNameMapper": {

"/^@\/(.*)$/": "C:\Users\user\git\vue 3\proj\src\$1"
  },
  "resolver": null

I upgraded this project to the new cli, and had to use SVGs differently to how we were using them before, and then came across this problem as one of the steps in the upgrade. We're using the loader vue-svg-sprite-loader in webpack to get this working. Previously, we were using :xlink:href within a component, but now we're using a component (e.g. < Close / >) .
Jest config is the same as default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproductionThis issue is missing a minimal runnable reproduction, provided by the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions