SimulatedGREG / electron-vue

An Electron & Vue.js quick start boilerplate with vue-cli scaffolding, common Vue plugins, electron-packager/electron-builder, unit/e2e testing, vue-devtools, and webpack.
https://simulatedgreg.gitbooks.io/electron-vue/content/
MIT License
15.48k stars 1.55k forks source link

Resolving dynamic files #883

Closed lgrcia closed 4 years ago

lgrcia commented 5 years ago

I would like to set the src of an <img> to the path of an image from a newly created folder (not existing at build time).

I know resolving assets questions are quite frequent but I cannot have the image created in the asset folder and webpack cannot resolve the path since the folder does not exists when compiling.

I tried a solution with app.getPath from electron but with no success.

Any advice?

lgrcia commented 5 years ago

Similar to #165, I tried to set webSecurity to false

lgrcia commented 5 years ago

Here is some proper context for my previous question (on a simple example):

Issue

Fresh electron-vue project with the following LandingPage.vue:

<template>
  <div id="wrapper">
    <img id="logo" src="/an_absolute_path/default.png" alt="electron-vue">
  </div>
</template>

Throw: Failed to load resource: the server responded with a status of 404 (Not Found)

Reproduction
vue init simulatedgreg/electron-vue another_test
cd another_test
npm install
npm run dev

and:

Development environment.
lgrcia commented 5 years ago

The file is propely resolved outside of development though.

After:

npm run build
...
open build/mac/another_test.app

app runs fine:

Capture d’écran 2019-05-24 à 10 52 28

Hope it'll help to spot an issue or a misunderstanding. Thank you for your time!