When compiling after updating from [email protected] 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.
Without reproducible test repo I can't help, sorry
Minimum - please provide full stack trace of an error
@blasterbug You should update how you call copy-webpack-plugin. I managed to make it work by doing the following:
module.exports = () => ({
//...
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: 'public',
globOptions: {
ignore: ['public/service-worker.js'],
},
},
],
}),
],
)}
Also mini-css-extract-plugin and copy-webpack-plugin uses difference hooks, please update the issue using template and I will reopen the issue, can't help without configurations/reproducible test repo/reproducible steps
this is how I set up the copy plugin:
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)
@blasterbug Reproduced
Looks like bug in globby
Also ignore does not work properly:
https://stackoverflow.com/questions/62172321/copy-webpack-plugin-v6-0-1-ignore-option-is-not-working
@Legends Please read my answer in the other issue
Up
Meanwhile, I found one solution for my own.
You can use this plugin remove-files-webpack-plugin to remove dist directory before compile & after compile you can remove map file or any specific file as per your requirement.
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
}
]
}
}),
gitig
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'],
},
},
],
}),
],
@gregbenz Feel free to send a fix to globby
@gregbenz Feel free to send a fix to
globby
@evilebottnawi Sorry, I'm not sure what you mean. What would I do to use the gitignore flag without errors?
Send a fix to globby, here issue https://github.com/sindresorhus/globby/issues/145
It is not problem by typescript, it is problem in globby package
It is not problem by typescript, it is problem in
globbypackage
Thank you for catching that, I had multiple tabs opened and copied to the wrong one. Deleted from TS and added to globby.
I got same errors after the upgrade the plugin both of them
its working with this configs
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/*'] },
},
],
});
Most helpful comment
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'], }, }, ], }), ],