Reputation: 1048
When I use the @vue/cli to create a vuejs project, I see that there is a folder /assets
that contains images and whatever I want. Than they can be referenced in the html such as <img src="@/assets/images/home.png" />
or import it on the js part.
My question is, why can't I just put the assets in /public/assets
and put directly <img src="/assets/images/home.png" />
in my code? Where is the advantage of these assets?
Upvotes: 0
Views: 334
Reputation: 2598
It allows Webpack to handle assets, which means it can merge/minify files (useful for JS and CSS), optimize images, and more importantly version them so that cache handling is improved.
Upvotes: 1