electron-userland / electron-userland/electron-webpack

static/ folder not copied when building

Open
#157 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
902
Forks
168
PR merge metrics
No merged PRs in 30d

Description

My folder structure is like this, using lerna:

```
.
├── lerna.json # Config for Lerna
├── package.json # Package.json for the whole repo
├── packages/
│ ├── crale-electron/
│ │ ├── electron-build.json # Config for electron-build
│ │ ├── electron-webpack.json # Config for electron-webpack
│ │ ├── dist/ # Binaries bundles by electron-builder
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── main/ # My electron app goes here
│ │ ├── static/
│ ├── crale-react
│ │ ├── build/ # The built app generated by CRA
│ │ ├── package.json
│ │ ├── src/ # My react app goes here
```

So my workflow is:
- I develop my react app inside `crale-react`, and build it inside its `build` folder
- I copy this `build` folder inside `crale-electron/static/build`, so that it's available via `__static` inside the Electron app
- When the Electron app starts, I loadUrl of `${__static}/build/index.html`. I don't use the renderer folder of electron-webpack.

My problem is, running the command `electron-webpack` builds everything correctly, but doesn't seem to copy the content of the `static/` folder. As a result, I have the following error when I run `electron dist/main/main.js`:

```
Not allowed to load local resource: file:///Users/amaurymartiny/Workspace/cra-lerna-electron/packages/crale-electron/node_modules/electron/dist/Electron.app/Contents/Resources/static/build/index.html
```

And indeed, having a look inside `crale-electron/node_modules/electron/dist/Electron.app/Contents/Resources/`, I see that there's no `static/` folder. Shouldn't there be one?

Here is a repo where you can repro this error: https://github.com/amaurymartiny/cra-lerna-electron

PS: running `electron-builder` on the same project produces working binaries.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.