how can i import a folder of images, tried this -
import * as img '../../images';
i want to get all the files inside of the folder and compare them to filenames.
how can i do that? maybe in another why?
how can i import a folder of images, tried this -
import * as img '../../images';
i want to get all the files inside of the folder and compare them to filenames.
how can i do that? maybe in another why?
Have a look on this How to import all modules from a directory in TypeScript?
The way you are trying is not possible.
Check this answer as well Typescript 1.8 modules: import all files from folder
You can use fs.readdirSync
to read the contents of a directory.
Example:
import fs from "fs"
let images = fs.readdirSync("../../images")
console.log(images)
/* Example output
["sun.png", "stars.jpeg", "icon.psd"]
*/