This is not possible in plain javascript because import/export are determined statically.
If you are using webpack, have a look at require.context . You should be able to do the following:
function importAll(r) {
return r.keys().map(r);
}
const images = importAll(require.context('./', false, /\.(png|jpe?g|svg)$/));
ref: https://webpack.js.org/guides/dependency-management/#require-context