Roots Discourse

Sage 10 Webpack Error

Hi there,

I’m using a class which references a varialbe that contains an Object.entries method which requires the path to images directory and selects all .jpg in the directory:

const images = Object.entries(require('../images/*.jpg'));

But I get a webpack error: Module not found: Error: Can’t resolve ‘…/images/*.jpg’

If I change ‘*’ to an actual filename in the directory the image gets added to the mix manifest and there are no errors however when I view dev tools the image is not found as its file path has been placed at the directory root rather than relative to the theme uri.

Is there a webpackConfig method that I can add to webpack.mix.js file to get this to resolve properly?

I’m only just getting started with Laravel mix so apologies if my query is unclear. Really loving Sage 10!

Many thanks in advance

You seem to require multiple files at once using a glob.

Do these posts help?:

Thank you so much starsis. I’ll have a look at these today