Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Resolving dynamic files #883

Closed
lgrcia opened this issue May 23, 2019 · 3 comments
Closed

Resolving dynamic files #883

lgrcia opened this issue May 23, 2019 · 3 comments

Comments

@lgrcia
Copy link

lgrcia commented May 23, 2019

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 lgrcia changed the title Resolving dynamic files Resolving dynamic files May 23, 2019
@lgrcia
Copy link
Author

lgrcia commented May 23, 2019

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

@lgrcia
Copy link
Author

lgrcia commented May 24, 2019

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:

mainWindow = new BrowserWindow({
    height: 563,
    useContentSize: true,
    width: 1000,
    webPreferences: {
      webSecurity: false
    },
  })
Screenshot of rendering error

Capture d’écran 2019-05-24 à 10 27 13

Development environment.
  • Node version: v12.1.0
  • NPM version: 6.9.0
  • vue version: 2.6.10
  • webpack version: 4.32.2
  • Operating System: OSX 10.14.5

@lgrcia
Copy link
Author

lgrcia commented May 24, 2019

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants