-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help on setting up Parcel for Electron development #1841
Comments
So I seem to have stumbled into a solution using the API method above. I commented out the:
Line, and the below works with If someone has a non-API method of getting the same result or better way or setting up Electron, I would still love to hear it. Thx.
|
Thanks for the sums up, I approve these issues since I've gone through all these steps too. I'd love to have a solution that just works, step #2 seems like the most intuitive way. |
I have the same problem. I try to use parcel to build my electron app but without success. Could we just serve app on localhost when using the |
Same problem, don't know what to do... In setup #1 I noticed that replacing |
Looks like it's being addressed for Parcel 2 #2492 Although that still appears to be a while away. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
❔ Question
What is the recommended way to set up an Electron project for development using Parcel for bundling. I have seen a number of boilerplate repos that user the Parcel development server to serve and hot-reload assets for development, however, if you try to user a node/Electron module, you get an expected error with
target=browser
.If you use
target=electron
, you don't get the development server starting up (per a previous issue cited below).I can source directly from my output folder, but that seems inelegant and hacky. Detail below. I feel like I am missing some small insight around Parcel and bundling to get this working smoothly.
🔦 Context
I ran through a few different setup to see what worked:
Setup #1 (start file = index.html, target=browser)
This loads, HMR works, however if you uncomment the
import { remote } from 'electron'
line inindex.js
it causes an expectedfs.existsSync
because its trying to use the node API with target=browser.Setup #2 (start file = index.html, target=electron)
If I try to remedy this by setting
target=electron
, everything seems to work fine but the dev server does not start so I can't link to it from my render process ->index.html
. I guess this is intentional per this issue, but in my user case this would be helpful.#1005
Is there a way to force it on, or is there a better way to setup this type of Electron project in general?
Setup #3 (start file = index.js, target=electron, source from
build/
folder)If I aim Parcel at just the render process
index.js
file, and source it directly from the output folder as../build/index.js
in theindex.html
file (you have to manually comment/uncomment the lines inindex.html
), the HTML renders, however, theimport './App.css'
in a JS file does not work for some reason. I have to link to it directly in the index.js file in the build folder (../build/index.css
). This all seems hacky but it does work and HMR works as well.Setup #4
I tried using creating
bundle-script.js
to for the dev server on while targeting a.js
file (target=electron + running the local dev server via middleware) but the HTML seems to be bundled up in a .js file which causes it to fail (Uncaught SyntaxError: Unexpected token <
).Honestly, I have not idea what I'm doing wrt to the Express server here.
💻 Code Sample
This is a very simple sample project which I used to do tests to get my real project working. The commands
https://github.com/rkpatel33/parcel-react-electron-example
🌍 Your Environment
The text was updated successfully, but these errors were encountered: