I'm using this as part of Laravel Mix 2.1.11, but I've isolated the problem to this plugin, the Webpack Stats object, or the former's use of the latter. Compiling our JS/SASS produces a warning on the initial run of yarn watch due to an image URL it thinks doesn't exist which is fine. Changing a SASS file causes the build to rerun, but this time the process halts with a type error "trying to access 'module' of undefined."
Line 28 sees that stats.hasWarnings() returns true, and line 29 sets error to the first element of the stats.compilation.warnings array, but this array is empty. Line 42 then tries to access error.module which kills the process.
Are there other sources of warnings besides the compilation object? If not, it looks like Webpack may actually be at fault here, but I don't know the Webpack codebase or API at all. Either way, it probably makes sense to check that error is truthy before accessing its properties.
I'm using this as part of Laravel Mix 2.1.11, but I've isolated the problem to this plugin, the Webpack Stats object, or the former's use of the latter. Compiling our JS/SASS produces a warning on the initial run of
yarn watch
due to an image URL it thinks doesn't exist which is fine. Changing a SASS file causes the build to rerun, but this time the process halts with a type error "trying to access 'module' of undefined."Line 28 sees that
stats.hasWarnings()
returns true, and line 29 setserror
to the first element of thestats.compilation.warnings
array, but this array is empty. Line 42 then tries to accesserror.module
which kills the process.I inserted the following before line 39:
This lets the build proceed after printing this:
Are there other sources of warnings besides the
compilation
object? If not, it looks like Webpack may actually be at fault here, but I don't know the Webpack codebase or API at all. Either way, it probably makes sense to check thaterror
is truthy before accessing its properties.I went with this solution for now before line 39: