template-rollup-typescript icon indicating copy to clipboard operation
template-rollup-typescript copied to clipboard

Unable to find module '.assets/...'

Open Qumeric opened this issue 5 years ago • 2 comments

Hi,

I have a Phaser 3 project in JS and I want to try to move it to typescript. Unfortunately, I am not able to figure out how to import image assets. I have tried a few different things from the web but nothing helps :( My imports currently look like this: import x from "./assets/x.png"

Could you please explain how to properly import assets?

Qumeric avatar Nov 24 '19 14:11 Qumeric

@Qumeric you can try on preload method: this.load.image('logo', 'assets/phaser3-logo.png'); then on create method: const logo = this.add.image(400, 70, 'logo');

Girdacio avatar Mar 27 '20 16:03 Girdacio

@Qumeric Having issue importing png, I found the solution by adding index.d.ts with only the line declare module '*.png' then in tsconfig.json : "include": [ "./src/**/*", "index.d.ts" ]

laurentsorin avatar Oct 22 '20 22:10 laurentsorin