Ignore specific module(s) when bundling assets, using Laravel Mix.
Read more about how ignoring module(s) work with the IgnorePlugin.
npm install laravel-mix-ignore --save-dev
String is given for either parameter, it's automatically converted to a
target/with/slashes is converted to:
The resource parameter is tested against the string passed to require or import within the source code where the import is taking place.
const mix = ;;// ignore bundling the following modulemix;
Following with the official documentation on the IgnorePlugin, you can also pass in filter functions for either the resource or context parameters.
As stated in the documentation, the filter function(s) must return a
Boolean value for the plugin to evaluate.
Adapting the official documentation's examples when dealing with moment locales, in order to properly ignore bundling them when importing or requiring moment, do the following:
With the following import statement with how moment imports its locale(s)...
...the first resource parameter should match against
./locale and the second context parameter should specify the directory or directories from where the import took place. The following will cause the locale files to be ignored in the proper context: