question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - why static asset logo.png is in the src/assets folder instead of static folder

See original GitHub issue

I was going to open an SO question for this, but this really is specific to this repo. I am only a few hours into using Vue (and so far am loving it) and was wondering if there is a reason or difference in placing assets such as images in the src folder versus the static folder? Most examples I have seen have thing like logo.png in the static folder (maybe under a sub-folder). This one has logo.png in the src/assets folder. Is there a reason behind that or does it really matter as long as it’s imported from the correct place?

AKA - does Vue or webpack treat these any based in where they are located between static or src? Just want to be sure before I shoot myself in the foot over something as simple as app structure.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
chrisvfritzcommented, May 29, 2016

The question is actually specific to this repo and it’s addressed in that repo’s docs.

7reactions
Akryumcommented, Mar 16, 2018

The use of static over assets is that URL is not changed and it performs better as browser already has the cached image.

Assets processed by weback will have the same URL as long as the content is the same, also taking advantage of the browser cache. By using static, you loose the automatic hash generated by webpack in the URL and it’s more difficult to change the base URL in your code. By using webpack, you can also automatically convert small images to data-url in base64 to avoid small unwanted network requests thanks to the url-loader.

tl:dr Just use webpack for your assets and put them in the src folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<v-img> doesn`t work with static image. [Vuetify] Image load ...
You're trying to request /assets which doesn't exist in your project, you only have /assets.img in there, so why are you requesting ...
Read more >
Static vs src/assets in Vue CLI Webpack Templates
Static vs src/assets in the Webpack template by Vue CLI ... A logical question that may follow is then: Why does the static...
Read more >
Images not loading from assets folder in Angular
Angular resolves this problem for you, and in a component, you have to only add a path to the assets folder, instead of...
Read more >
Handling Static Assets · GitBook
logo.png" is a relative asset path and will be resolved by Webpack as a module ... component in its own directory, with its...
Read more >
App Handling Assets | Quasar Framework
imageSrc: 'logo.png' } } } </script>. You can force serving static assets by binding src to a value with Vue. Instead of src="path/to/image"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found