EuberDeveloper
EuberDeveloper

Reputation: 1048

Vue.js - Why should I put images on /assets instead of putting them directly in /public

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

Answers (1)

Terenoth
Terenoth

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

Related Questions