-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module "../static/icons/my-icon" #29
Comments
Same here, using nextjs@latest (canary) and TS. |
Oh - actually, i got it to work like this:
Note the missing "../". The way this is described in the "how to" section is kinda broken perhaps? "./images/.." should resolve to "(root)/static/images" but results in a "module not found" error for me as well. Using both "../static/.." and "/static/.." results in an image being picked up but using query params will fail in both cases. Only "static/.." works with query params. |
hmmm, unfortunately it's not working for me :( |
Running on these dependencies:
Either way, the way file references are documented in the |
Hello, and sorry for the late reply. I was on vacation and didn't take the laptop with me. It looks like TypeScript doesn't know about the webpack query parameters. @genox in the readme, it is assumed that you have an // types/next-optimized-images.d.ts
declare module '*.png';
declare module '*.png?include';
declare module '*.png?webp';
declare module '*.png?inline';
declare module '*.png?url';
declare module '*.png?original';
declare module '*.jpg';
declare module '*.jpg?include';
declare module '*.jpg?webp';
declare module '*.jpg?inline';
declare module '*.jpg?url';
declare module '*.jpg?original';
declare module '*.jpeg';
declare module '*.jpeg?include';
declare module '*.jpeg?webp';
declare module '*.jpeg?inline';
declare module '*.jpeg?url';
declare module '*.jpeg?original';
declare module '*.webp';
declare module '*.webp?include';
declare module '*.webp?webp';
declare module '*.webp?inline';
declare module '*.webp?url';
declare module '*.webp?original';
declare module '*.svg';
declare module '*.svg?include';
declare module '*.svg?webp';
declare module '*.svg?inline';
declare module '*.svg?url';
declare module '*.svg?original';
declare module '*.svg?sprite';
declare module '*.gif';
declare module '*.gif?include';
declare module '*.gif?webp';
declare module '*.gif?inline';
declare module '*.gif?url';
declare module '*.gif?original'; |
Thanks for the typings. Now I also understand why it didn't work. :) I did in fact assume that assets are centralised, not per module. Depending on your architecture (e.g. ARC/atomic react components), this is unfeasible, but if it can be configured, that's great. Will give it a try once the dependency things have been sorted out. |
Hi,
when I try to use any of the query params like "?url" I get an error
Cannot find module "../static/icons/my-icon"
so this works:
<img src={require('../static/icons/my-icon.svg')} width="100%" height="100%"/>
... but this doesn't:
<img src={require('../static/icons/my-icon.svg?url')} width="100%" height="100%"/>
(I'm using Typescript)
Thanks in advance!
The text was updated successfully, but these errors were encountered: