In PHP I have the following code to create an array of all images in a directory.
$dir = '/public/images/';
$files = scandir($dir);
What would the NodeJS equivalent be?
I am looking to create an array of all images in a directory.
Using this in Laravel webpack mix in development so it would run either on the local machine or on the server itself by command line.
Instead of the following as there is an unknown number of images in the directory and what the name would be.
if (mix.config.inProduction) {
mix.version(['public/images/50x50-1.png', 'public/images/50x50-1.svg'])
}
Desired Code:
if (mix.config.inProduction) {
var imagesArray = // get the list here
mix.version(imagesArray)
}
via Jeff
No comments:
Post a Comment