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
Excluding single files #294
Comments
Currently, this is what's being used: webpackConfig
.plugin('copy')
.use(require('copy-webpack-plugin'), [[{
from: publicDir,
to: outputDir,
toType: 'dir',
ignore: publicCopyIgnore
}]]) where publicDir is the absolute path to the "public" and outputDir the absolute path to "dist". publicCopyIgnore might look something like this: |
@ivansieder interesting, can you provide minimum reproducible repo with example what you actually have and expected. Why |
@evilebottnawi repo could be used this one: https://github.com/ivansieder/vue-cli-nested-index-files-bug. Right now, vue cli is passing ["index.html", ".DS_Store"] to the copy-webpack-plugin, which means, that the glob is being matched with index.html, which in turn means, that public/index.html, public/other/index.html, public/some/extremely/nested/one/index.html all would be ignored. That's why ignore in this case won't work really rell in my opinion (maybe there's a way around that which I don't know yet). The repo above should be installed and inside node_modules, there's the @vue/cli-service/lib/config/app.js file and at the really bottom, there's the copy-webpack-plugin being configured. Does that help or do you need some additional information? |
@ivansieder what about implement |
@evilebottnawi what could such a function possibly look like? |
@ivansieder depends what information you need to detect should you ignore or not |
@evilebottnawi just talking about vue cli (but I think this could be useful in other cases, too), a function which gets called with the current webpackConfig
.plugin('copy')
.use(require('copy-webpack-plugin'), [[{
from: publicDir,
to: outputDir,
ignore: publicCopyIgnore,
ignoreFunction(file) {
return publicCopyIgnoreFiles.includes(file.relativeFrom)
}
}]]) |
@ivansieder why not pass |
someone might be interested in the absolute path, too. This also keeps it open for eventual future additions. And if you really want just the relativeFrom, you could still do something like this: ignoreFunction({ relativeFrom }) {
return publicCopyIgnoreFiles.includes(relativeFrom)
} |
alternative would be of course to let the user only pass an array with strings and then do everything internally (checking, if it's relative path or not), but I guess that would incur too many edge cases that would have to be covered. And having a function like this leaves the flexibility up to the user, which implements it. |
@ivansieder Yes, PR welcome 👍 |
Just came up with a fix: vuejs/vue-cli#4613
|
Awesome, thanks @sodatea |
The Vue CLI offers the possibility to use the public/ directory, which will copy it's files 1:1 to the dist/ folder when it's being built. That's what copy-webpack-plugin is being used for.
Now additionally, some of the .html-files from public/ are being are being used just as templates for html-webpack-plugin to auto-inject scripts. That means, that these files don't need to be copied to the final dist/ folder. The issue which arises now is, that using the "ignore" property for this won't work all too well, as using "index.html" for example would mean that it's using "index.html" as a glob and therefor excluding all index.html files.
Is there any way to exclude single files with relative paths (i.e. "public/index.html", "public/other/index.html" etc. or what would be the correct approach to handle these cases?)
The text was updated successfully, but these errors were encountered: