【发布时间】:2021-08-16 05:37:48
【问题描述】:
我有一个使用 create-react-app --template typescript 启动的项目。我需要使用 webpack raw-loader 导入一些文件,所以我做了一个npm i -D raw-loader。现在我像这样导入那些:
// eslint-disable-next-line import/no-webpack-loader-syntax
import fSrc from '!!raw-loader!./something.glsl';
我为我的项目添加了 .glsl 文件的声明以及 !raw-loader!:
// index.d.ts
declare module '*.svg';
declare module '*.glsl';
declare module '!raw-loader!*';
但是,我得到编译器错误:
Cannot find module '!!raw-loader!./something.glsl' or its corresponding type declarations. TS2307
1 | // eslint-disable-next-line import/no-webpack-loader-syntax
> 2 | import fSrc from '!!raw-loader!./something.glsl';
我在这里做错了什么?
【问题讨论】:
-
你解决过这个问题吗?我遇到了同样的问题。
-
我做到了。我发布了一个答案
标签: typescript webpack create-react-app raw-loader