webview’s preload script cannot be found in production
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 641
- Avg merge
- 3d 17m
- Merged PRs (30d)
- 32
Description
My `preload.js` file is in `src/components/MyComponent` folder. And my other file containing `webview` is like following:
```js
const getSourceDirectory = () =>
process.env.NODE_ENV === "development"
? path.join(process.cwd(), "src/components/MyComponent") // or wherever your local build is compiled
: path.join(process.resourcesPath) // asar location
const preload = `file://${path.resolve(getSourceDirectory(), 'preload.js')}`
```
And I include it like:
```js
```
This works in `development` because I know the path. I can’t seem to find the path in `production` though.
And if I put the same path as `development`, i.e, `"src/components/MyComponent"` then it says `Can’t find preload.js` which is obvious.
How do I make this thing work in `production` with `electron-forge`?
I know the error is in the `else` condition of the ternary operator, i.e, `path.join(process.resourcesPath)` should be changed to something else but what should it be changed to?
Contributor guide
Assessment
This issue has not been assessed yet.