[尝试使用汇总来预加载图像时出现问题。所有应该起作用的废话都没有,不知道为什么。是否有人设法使其正常工作?这是我在rollup.congig.js中拥有的内容:
import image from 'rollup-plugin-image'
...
plugins: [
image(),
json(),
resolve(),
commonjs(),
typescript({
typescript: require('typescript'),
}),
(process.env.BUILD === 'production' ? terser() : {})
这是我的资料来源:
import CAR_IMAGE from "../resources/expand.png";
最后,我从rtp2插入中收到一条错误消息:
语义错误TS 2307,找不到模块“ ../ resources / expand.png”
奇怪的是,我与用于汇总的其他各种图像加载插件都一样。路径正确,图像在那里。我已经为这个错误而烦恼=((
更新:这是可复制此错误的存储库:
https://github.com/AntonPilyak/rollup-image-bug
更新2:已创建错误:
https://github.com/rollup/rollup-plugin-url/issues/22
https://github.com/alwaysonlinetxm/rollup-plugin-img/issues/5
https://github.com/rollup/rollup-plugin-image/issues/10
怎么会这么烂? =((((
替换rollup-plugin-image软件包。并在下面的插件中添加类似的内容
plugins: [
image({
extensions: /\.(png|jpg|jpeg|gif|svg)$/,
limit: 10000
}),........
然后在根项目中创建文件名declaration.d.ts
。在以下代码段中添加
declare module '*.png' {
const value: any;
export default value;
}
将此片段添加到您的tsconfig.json
"include": ["src","src/declaration.d.ts"],
在CLI中重新运行汇总。会工作的!👍