question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does anyone know how to get this working with Create-React-App ? I’ve been struggling all day and I am still nowhere forward 😦

It works if I build the CRA itself BUT I have to keep doing this every time I change something. Create-REact-App comes with it’s own Dev server that hot reloads and I wanted to be able to plug into it but when I do a console.log(eel) it always prints undefined.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
ahopkinscommented, Mar 7, 2018

I played around with this for just a few minutes. I did it using VueJS instead, but the concept should be the same. It is not yet an elegant solution, but it works without making any modifications to Eel.

Files

Here is my file structure.

.project
β”œβ”€β”€ app.py
β”œβ”€β”€ start.sh
└── web
    β”œβ”€β”€ build
    β”œβ”€β”€ config
    β”œβ”€β”€ index.html
    β”œβ”€β”€ node_modules
    β”œβ”€β”€ package.json
    β”œβ”€β”€ README.md
    β”œβ”€β”€ src
    β”œβ”€β”€ static
    └── yarn.lock

Here is start.sh:

#!/bin/bash

cd web
yarn run dev

And, here is app.py

import eel
import threading
from subprocess import call
from time import sleep


def start_web():
    call(['./start.sh'])


def start_eel():
    sleep(4)
    eel.init('web')
    eel.start('', options={
        'port': 8080,
        'host': 'localhost',
    })


if __name__ == '__main__':
    t1 = threading.Thread(target=start_web)
    t2 = threading.Thread(target=start_eel)
    t1.start()
    t2.start()

Plan

As you can see, the idea is simple: start both the eel webserver, and whatever other webserver you want. Then, tell the eel browser to open your other webbrowser instead of a static file.

Pitfalls

I hacked this together in just a few minutes as a proof of concept. Clearly we can improve upon this, and looks like something that we could and should be able to bake into eel itself.

As you can see, I needed to throw a sleep in there just to make sure the webpack server was up and running first. This needs to be fixed.

Maybe also there is a better solution to using Threading

This may not be the best solution, but it does work. I was able to startup the servers, and make changes to my Vue app and have it live reload inside of the eel browser.

Kudos to @ChrisKnott for an awesomely simple and elegant implementation.

1reaction
ahopkinscommented, Mar 10, 2018

You would need to stash a local copy of the eel repo, and make the change. I have not committed it.

git clone https://github.com/ahopkins/Eel.git

Then, install that.

pip install -e /path/to/Eel

Go into Eel/eel/__init__.py and add .tsx into allowed_extensions as shown above. That will get it working for now until there is a solution. Your alternative would be to define all of your eel methods in a file with a .js extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App
Create React App Β· Less to Learn. You don't need to learn and configure many build tools. Instant reloads help you focus on...
Read more >
Create a New React App
Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in...
Read more >
facebook/create-react-app - GitHub
Set up a modern web app by running one command. Contribute to facebook/create-react-app development by creating an account on GitHub.
Read more >
create-react-app - npm
Create React apps with no build configuration. ... Start using create-react-app in your project by running `npm i create-react-app`.
Read more >
How To Set Up a React Project with Create React App
Step 1 β€” Creating a New Project with Create React App. In this step, you'll create a new application using the npm package...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found