Having trouble preloading an image with Rollup. None of the solutions that should work seem to be effective, and I can't figure out why. Has anyone successfully managed to make this work? Here is my configuration in rollup.config.js:
import image from 'rollup-plugin-image'
...
plugins: [
image(),
json(),
resolve(),
commonjs(),
typescript({
typescript: require('typescript'),
}),
(process.env.BUILD === 'production' ? terser() : {})
This is what I have in my source:
import CAR_IMAGE from "../resources/expand.png";
But I keep getting an error from the rtp2 plugin which reads:
Semantic error TS 2307, cannot find a module "../resources/expand.png"
What's strange is that I encounter the same issue with different image-loading plugins for Rollup. The path is correct, the image is there. This error is driving me crazy =((
Update: I have created a repository to reproduce this bug:
https://github.com/AntonPilyak/rollup-image-bug
Update 2: I have reported these bugs:
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
Why is it so frustratingly difficult? =(((