opened
blasterbug
username_0
When compiling after updating from copy-webpack-plugin@6.0.0 to 6.0.1, I got this error (that seems be thrown by mini-css-extract-plugin). 
"""
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
"""

I am not sure if it's an actual bug, but I post this here since the only thing that changed when I got this bug was the version for mini-css-extract-plugin. 

I can try to make a minimal project to reproduce the errors, but seems overkill for me right now. 

- Operating System: MacOS 10.15.4 (happen also int he Google Cloud build environment)
- Node Version: 14.2.0 (and node:13-alpine on Gcloud build)
- NPM Version: 6.14.5
- webpack Version: 4.43.0
- copy-webpack-plugin Version: 6.0.1
ERROR in The "path" argument must be of type string. Received an instance of Object
issue
created
evilebottnawi
username_1
Without reproducible test repo I can't help, sorry
comment
created
evilebottnawi
username_1
Minimum - please provide full stack trace of error
comment
created
TheCapedBaldi
username_2
@username_0 You should update how you call `copy-webpack-plugin`. I managed to make it work by doing the following:

```js
module.exports = () => ({
  //...
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        {
          from: 'public',
          globOptions: {
            ignore: ['public/service-worker.js'],
          },
        },
      ],
    }),
  ],
)}
```.
comment
created
evilebottnawi
username_1
Also mini-css-extract-plugin and copy-webpack-plugin uses difference hook, please update the issue using template and will reopen the issue, can't help without configurations/reproducible test repo/reproducible steps
comment
closed
evilebottnawi
username_1
issue
created
blasterbug
username_0
this is how I set up the copy plugin:
```javascript
new CopyWebpackPlugin({
        patterns: [
          {
            from: path.resolve(__dirname, 'public'),
            to: path.resolve(__dirname, 'dist'),
            globOptions: {
              dot: true,
              gitignore: true,
              ignore: [
                '*.html',
                '*.svg',
              ],
            },
          },
        ],
      }),
```

And this what I've got:
```
Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js??ref--4-1!node_modules/postcss-loader/src/index.js??postcss!node_modules/sass-loader/dist/cjs.js!src/styles/main.scss:
    Entrypoint mini-css-extract-plugin = *
    [9f2e4028ce7cb94562a7cbb58ade39bc] ./node_modules/css-loader/dist/cjs.js??ref--4-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/dist/cjs.js!./src/styles/main.scss 12 KiB {0} [built]
        + 1 hidden module
    
    ERROR in The "path" argument must be of type string. Received an instance of Object
(node:90113) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
```
comment
reopened
evilebottnawi
username_1
When compiling after updating from copy-webpack-plugin@6.0.0 to 6.0.1, I got this error (that seems be thrown by mini-css-extract-plugin). 
"""
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
"""

I am not sure if it's an actual bug, but I post this here since the only thing that changed when I got this error is the version for mini-css-extract-plugin. 

I can try to make a minimal project to reproduce the errors, but seems overkill for me right now. 

- Operating System: MacOS 10.15.4 (happen also int he Google Cloud build environment)
- Node Version: 14.2.0 (and node:13-alpine on Gcloud build)
- NPM Version: 6.14.5
- webpack Version: 4.43.0
- copy-webpack-plugin Version: 6.0.1
ERROR in The "path" argument must be of type string. Received an instance of Object
issue
created
evilebottnawi
username_1
@username_0 Reproduced
comment
created
evilebottnawi
username_1
Looks like bug in `globby`
comment
created
evilebottnawi
username_1
https://github.com/sindresorhus/globby/issues/145
comment
created
Legends
username_3
Also ignore does not work properly:
https://stackoverflow.com/questions/62172321/copy-webpack-plugin-v6-0-1-ignore-option-is-not-working
comment
created
evilebottnawi
username_1
@username_3 Please read my answer in the other issue
comment
created
liesahead
username_4
Up
comment
created
AmreeshTyagi
username_5
Meanwhile, I found one solution for my own.

You can use this plugin [remove-files-webpack-plugin](https://github.com/Amaimersion/remove-files-webpack-plugin/blob/master/README.md) to remove dist directory before compile & after compile you can remove map file or any specific file as per your requirement. 

``` javascript
 new RemovePlugin({
          /**
           * Before compilation permanently removes production build directory dist folder 
           * Log only works for warnings and errors.
           */
          before: {
              include: [
                path.join(__dirname, 'server/dist')
              ],
              log: false,
              logWarning: true,
              logError: true,
              logDebug: false
          },
          after: {
            test: [
                {
                    folder: path.join(__dirname, 'server/dist'),
                    method: (absoluteItemPath) => {
                        return new RegExp(/\.map$/, 'm').test(absoluteItemPath);
                    },
                    recursive: true
                }
            ]
        }
      }),
```
comment
created
gregbenz
username_6
With copy-webpack-plugin 6.0.3, I'm also getting  "ERROR in The "path" argument must be of type string. Received an instance of Object". The error is just that, no additional information and there is no clear indication that the failure is coming from copy-webpack-plugin (but it definitely is).

The error goes away if I do not use **gitignore: true**

My configuration: 
	```
plugins: [
		new CopyPlugin({
			patterns: [
				{
					from: './',
					to: '../dist/',
					context: './src/',
					globOptions: {
						dot: true,
						// gitignore: true, //In "copy-webpack-plugin": "^6.0.3", causes: ERROR in The "path" argument must be of type string. Received an instance of Object
						ignore: ['**/*.ts', '**/*.tif*', '**/*.tif', '**/*.md', '**/*.js', '**/libs/**', '**/*.doc'],
					},
				},
			],
		}),
	],

```
comment
created
gregbenz
username_6
Sorry, I'm not sure what you mean. What would I do to use the gitignore flag without errors?
comment
created
evilebottnawi
username_1
Send a fix to `globby`, here issue https://github.com/sindresorhus/globby/issues/145
comment
created
gregbenz
username_6
Thank you, updated https://github.com/microsoft/TypeScript/pull/35813
comment
created
evilebottnawi
username_1
It is not problem by typescript, it is problem in `globby` package
comment
created
gregbenz
username_6
Thank you for catching that, I had multiple tabs opened and copied to the wrong one. Deleted from TS and added to globby.
comment
created
emresandikci
username_7
I got same errors after the upgrade the plugin both of them 

its working with this configs

```js
const htmlPackPlugin = new HtmlWebPackPlugin({
  filename: 'index.html',
  template: 'src/public/index.html',
  hash: true,
});
const webpackCopyPlugin = new CopyWebpackPlugin({
  patterns: [
    {
      from: 'src/public',
      globOptions: { ignore: ['svg/*', '*.html', 'images/*'] },
    },
  ],
});
```
comment
closed
alexander-akait
username_8
issue