svg-sprite-loader icon indicating copy to clipboard operation
svg-sprite-loader copied to clipboard

svg-sprite-loader #undefined with next-images || next-optimized-images

Open hongkongk opened this issue 5 years ago • 3 comments

Screen Shot 2563-03-22 at 13 08 24

** environment:**

  • Node.js version: v12.12.0
  • webpack version: 4.36.1
  • svg-sprite-loader version: 4.2.1
  • OS type & version: 10.12.6 "next-optimized-images": "^2.5.5",

hongkongk avatar Mar 22 '20 13:03 hongkongk

Could you please create repo with minimal setup to demonstrate a problem (package.json, webpack config, SVG image and piece of your code). If you don't want to create a repository - you can create a gist with multiple files.

kisenka avatar Apr 12 '20 13:04 kisenka

Thanks, I have fixed it.

hongkongk avatar Apr 13 '20 00:04 hongkongk

Overwriting our global typing in TypeScript to make svg imports work with react-inline-svg.

Workaround is to use path mapping to redirect next-images typing to a custom file.

tsconfig.json

{
  "compilerOptions": {
    ...
    "paths: { 
      "next-images": ["./local_types/whatever.d.ts"]
    }
  }
}

./local_types/whatever.d.ts

// type for react-inline-svg
declare module '*.svg' {
  const content: any;
  export default content;
}

// copy rest of types
...

denizkoele avatar Sep 16 '20 16:09 denizkoele