Bin*_*men 3 typescript webpack next.js
我在 NextJS 应用程序中使用 useSound,并且我想播放位于 /public/static 中的 mp3:
import notification from "../../public/static/notification.mp3"
Run Code Online (Sandbox Code Playgroud)
它在运行时工作yarn dev(正在播放声音,没有错误),但在使用以下命令构建时会引发错误yarn prod:
Type error: Cannot find module '../../public/static/notification.mp3' or its corresponding type declarations.
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?我一直在浏览 internet/SO/github,并尝试了几件事,包括修改next.config.js:
Type error: Cannot find module '../../public/static/notification.mp3' or its corresponding type declarations.
Run Code Online (Sandbox Code Playgroud)
没有成功..
好吧,显然就这么简单:更新next-env.d.ts为
declare module '*.mp3' {
const src: string;
export default src;
}
Run Code Online (Sandbox Code Playgroud)
如果有人能解释它是如何工作的,那就太好了。
| 归档时间: |
|
| 查看次数: |
2079 次 |
| 最近记录: |