create-react-library icon indicating copy to clipboard operation
create-react-library copied to clipboard

Can't use library created with create-react-library in Next.js application

Open danfsd opened this issue 5 years ago • 1 comments

Hey, I'm trying to use a library that I developed using create-react-library in a Next.js application, but I'm getting this error:

[ error ] ./node_modules/<redacted>/<redacted>/dist/my-asset.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

The SVG file is placed alongside one of my Library's components and to use it I'm simply importing it and using on an img src attribute:

import myAsset from './assets/my-asset.svg`;

const Component = (props) => {
  return (
    ...
    <img src={myAsset}>
    ...
  );
};

export default Component;

Any clues? Thanks.

danfsd avatar Jun 05 '20 20:06 danfsd

Hi! I'm not sure if the problem is coming from CRL, a SVG is by default not supported and needs a loader. If you are using webpack, you would maybe need to have a look at this post: https://stackoverflow.com/questions/55175445/cant-import-svg-into-next-js Let me know if you need some further help!

psyycker avatar Jun 17 '20 21:06 psyycker