laravel-mix-imagemin
                                
                                
                                
                                    laravel-mix-imagemin copied to clipboard
                            
                            
                            
                        Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
Hello! I get this error.
Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 options[0] should be an object:
   object { patterns, options? }
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
    at validate (.\node_modules\copy-webpack-plugin\node_modules\schema-utils\dist\validate.js:96:11)
    at new CopyPlugin (.\node_modules\copy-webpack-plugin\dist\index.js:24:30)
    at Imagemin.webpackPlugins (.\node_modules\laravel-mix-imagemin\src\Imagemin.js:31:13)
    at ComponentFactory.applyPlugins (.\node_modules\laravel-mix\src\components\ComponentFactory.js:167:23)
    at .\node_modules\laravel-mix\src\components\ComponentFactory.js:71:26
    at .\node_modules\laravel-mix\src\Dispatcher.js:34:47
    at Array.forEach (<anonymous>)
    at Dispatcher.fire (.\node_modules\laravel-mix\src\Dispatcher.js:34:28)
    at Mix.dispatch (.\node_modules\laravel-mix\src\Mix.js:118:25)
    at WebpackConfig.buildPlugins (.\node_modules\laravel-mix\src\builder\WebpackConfig.js:103:13)
    at WebpackConfig.build (.\node_modules\laravel-mix\src\builder\WebpackConfig.js:24:14)
    at Object.<anonymous> (.\node_modules\laravel-mix\setup\webpack.config.js:29:38)
    at Module._compile (.\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (.\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
My code:
mix.imagemin(
        'images/**/**.*', {
            context: 'resources'
        }, {
            optipng: {
                optimizationLevel: 5
            },
            jpegtran: null,
            plugins: [
                require('imagemin-mozjpeg')({
                    quality: 100,
                    progressive: true,
                }),
            ],
        }
    )
                                    
                                    
                                    
                                
I have the same problem, i changed
'img/**.*'
to
{ patterns: [ { from: 'img/**.*', to: 'public/img' } ] }
to match this signature: https://webpack.js.org/plugins/copy-webpack-plugin/#options
but now I get this error: TypeError: glob pattern string required at new Minimatch
Temporary solution: https://github.com/CupOfTea696/laravel-mix-imagemin/issues/9#issuecomment-639407324
+1
Is this possible to update the options for copy-webpack-plugin please ?
Index: README.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- README.md	(revision 306369543ca2c0de498732d1622aeaadb7cea57f)
+++ README.md	(revision dcc6772017803e59f141032b715f3ae8d4cc5b49)
@@ -47,7 +47,9 @@
     .imagemin(
         'img/**.*',
         {
-            context: 'resources',
+            patterns: [
+                { from: 'resources', to: 'public' },
+            ],
         },
         {
             optipng: {
Index: src/Imagemin.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Imagemin.js	(revision 306369543ca2c0de498732d1622aeaadb7cea57f)
+++ src/Imagemin.js	(revision dcc6772017803e59f141032b715f3ae8d4cc5b49)
@@ -28,7 +28,7 @@
         let {patterns, copyOptions, imageminOptions} = this;
 
         return [
-            new CopyWebpackPlugin(patterns, copyOptions),
+            new CopyWebpackPlugin(copyOptions),
             new ImageminPlugin(imageminOptions),
             new ManifestPlugin(patterns),
         ];
                                    
                                    
                                    
                                
Further fuel to that fire...
# Run  npm install --save-dev [email protected]  to resolve 1 vulnerability
SEMVER WARNING: Recommended action is a potentially breaking change
 High                    Remote Code Execution                                        
 Package              serialize-javascript                                         
 Dependency of  copy-webpack-plugin [dev]                                    
 Path                    copy-webpack-plugin > serialize-javascript                   
 More info           https://npmjs.com/advisories/1548                            
found 1 high severity vulnerability in 1779 scanned packages
  1 vulnerability requires semver-major dependency updates.
                                    
                                    
                                    
                                
Has there been any resolution on this? I'd rather not use the solution in #9 if possible since it introduces a security vulnerability.
@CupOfTea696 any chance this can get fixed? copy-webpack-plugin is the only dependency that has to remain outdated at a lower version.
I needed this for few projects so I forked this repo to TooDotsLtd/laravel-mix-imagemin. It's been quiet here for too long to just ignore the issue!
How to use my fork?
In your package.json find line referencing laravel-mix-imagemin and change it to:
"laravel-mix-imagemin": "github:TooDotsLtd/laravel-mix-imagemin",
and run npm update.
Hi @ryanw3b3r, we have been using your fork successfully for quite some time to get around this issue in the base extensions, however it seems your GitHub repo has been removed, so the fork is no longer working. Is this temporary, or could you please reupload? Thanks.
Hi @alexryans, sorry but we've had to delete this fork due to changes in company's t&c's. I think you can still use @mariovalney's fork from https://github.com/mariovalney/laravel-mix-imagemin but contact the owner to confirm.
@ryanw3b3r No worries, thanks for getting back to me so quickly!
I've been maintaining this fork, which is also published on NPM.