-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
globOptions.ignore not work expected #689
Comments
Sorry, problem is not in the plugin, all options from |
same issue copy-webpack-plugin @5.x new CopyPlugin(
[
{
from: 'public',
to: '/XXX/dist',
toType: 'dir',
ignore: [
'.DS_Store',
{
glob: 'index.html',
matchBase: false
}
]
}
]
) copy-webpack-plugin @11.x (ignore option not working) new CopyWebpackPlugin({
patterns: [
{
from: 'public',
to: /XXX/dist,
toType: 'dir',
globOptions: {
ignore: [ '.DS_Store', 'index.html' ]
}
}
]
}) |
Please use |
when i use it to build new CopyWebpackPlugin({
patterns: [
{
from: 'public',
to: /XXX/dist,
toType: 'dir',
globOptions: {
ignore: [ 'index.html' ]
}
}
]
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'public/index.html',
title: projectName
}) I got ERROR in Conflict: Multiple assets emit different content to the same filename index.html now, if i use this new CopyWebpackPlugin({
patterns: [
{
from: 'public',
to: /XXX/dist,
toType: 'dir',
globOptions: {
ignore: [ '**/index.html' ]
}
}
]
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'public/index.html',
title: projectName
}) i got ERROR in unable to locate '/XXX/public/**/*' glob |
It means you have multiple files with different content:
|
yes, so i need to ignore |
Try to experiment, ignore is working, just with some limitations |
it's work for me. just add globalOptions-ignore my webpack.common.js new webpack.DefinePlugin({
BASE_URL: JSON.stringify('/'),
}),
new HtmlWebpackPlugin({
// 指定模板,此插件仍然会创建文件
title: 'Typescript + Vue',
template: '/public/index.html', // 如果使用自己的模板需要另外引入favicon图标
// favicon: '../public/favicon.ico',
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, '../public'),
to: path.resolve(__dirname, '../dist'),
toType: 'dir',
globOptions: {
dot: false, // 允许匹配以 . 开头的文件, 比如 .gitignore
gitignore: false,
ignore: ['.DS_Store', '**/index.html'],
},
},
],
}),
|
I had the same problem |
It means globby can't find directory |
兄弟我复制你的发现也不报错了,啥原理啊这是,我听着有点迷糊 |
刚看错了,还是报错啊兄弟 |
I'm not sure I completely understand if this will help OP, but I wanted to ignore specific files in the This is how I got it to work: patterns: [{ from: "./static", filter:(filepath) => {
const ignorePaths = ['/static/index.html']
const doCopy = ignorePaths.every(path => !filepath.endsWith(path))
return doCopy;
} }] For my case, since I am ignoring one file, a simple |
oh! It's a good solution.The only shortcoming is I can't use cases like 'public/**.html',but I think I can use regex to fix that |
Definitely! Something like return /public\/.*\.html$/.test(filepath) |
globalOptions.ignore seems only work on alone '**/index.html' but i can use fliter option hahaha. |
hi @alexander-akait ,I encountered the same problem as above. |
@Sober-1 hm, can you create reproducible test repo? it should work |
@alexander-akait |
Do you have the |
I used " noErrorOnMissing: true", Now the problem has been solved. thank you |
Change |
Bug report
When I use Copy Plugin follow README, it does not work like README said.
And I check issues, after use someone's method, it work, but not work well in sometimes;
Actual Behavior
I use Copy Plugin to copy dir
public
in my project root dir to webpack output path's dirpublic
,And I follow the config in README's globOptions descriptionn
it doesn't work at all. plugin will copy all the files in public;
and after search I found here ignoring-files in Readme.
but it doesn't work, still copy all files.
and I found something in issues, try #498 said that I add path.posix function to
ignore
property, it work, but only work on one file...if I specific more than one file use path.posix, it throw error
Expected Behavior
It should ignore public/index.html and public/asdasd.md files when copy to webpack output folder.
How Do We Reproduce?
I create a demo repo.
just run
pnpm install && pnpm run build
ORnpm install && npm run build
.Please paste the results of
npx webpack-cli info
here, and mention other relevant informationSystem:
OS: macOS 12.3.1
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 38.72 MB / 16.00 GB
Binaries:
Node: 18.1.0 - ~/.nvs/default/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.8.0 - ~/.nvs/default/bin/npm
Browsers:
Chrome: 100.0.4896.127
Firefox: 100.0
Safari: 15.4
Packages:
copy-webpack-plugin: ^10.2.4 => 10.2.4
webpack: ^5.72.0 => 5.72.0
webpack-cli: ^4.9.2 => 4.9.2
The text was updated successfully, but these errors were encountered: