Closed NE-SmallTown closed 3 years ago
Yes, expected, because other plugins can use this assets for any purpose, we can't remove it, anyway you don't have code for this import in your bundle
@evilebottnawi Thanks for your reply.
But as I said, "This will waste space of the server if we upload it when we publish every time" which is a problem
Is there any way to know whether the file be used? If so, I can write a custom emitFile
But as I said, "This will waste space of the server if we upload it when we publish every time" which is a problem
Just avoid unnecessary imports
Is there any way to know whether the file be used? If so, I can write a custom emitFile
No
Just avoid unnecessary imports
I think this is not very easy just like we need tree-shaking rather than avoid unnecessary imports
No
But from "because other plugins can use this assets for any purpose, we can't remove it", seems(myabe I misunderstand) there is a way to know "whether the file be used", just because "other plugins can use this assets for any purpose", so you still "can't remove it" even you know the file not be used?
there is a way to know "whether the file be used"
No ways, so we can't remove it
But you can write own plugin for this, but it will be not easy
For example my plugin can create robots.txt
file based on assets
Feature Proposal
I'm not familar with webpack and file-loader, so I don't know if it's possible to achieve this
Feature Use Case
Currently if we import an image(like
import foo from "../../common/images/hello.png"
) but not be used, the bundle result will not have variablefoo
because it has been tree-shaken.But, we will find that there is still an image file(like
hello-hash.png
) in the webpack output path directory because we always callemitFile
. This will waste space of the server if we upload it when we publish every time