It is recommended to build the svelte files into a static html page using npm run build, and then use Pyinstaller to build the exe with the build folder (which contains the npm run build commmand's output) as extra data. It is not gauranteed to be portable when packaged using Pyinstaller (We havent tested its cross system compatibility, The exe works fine in the same system in which it was packaged, but causes dll error when copied and pasted and ran in a different system).
reading this is recommended
The frontend is built using svelte. To compile svelte into a working html file, use:
npm run buildRun this in your terminal in the project directory.
This will generate index.html with other required files inside the build folder.
Use the index.html file to host it in a pywebview window (the window is created by host.py file).
Please use host.py file to host the index.html. Feel free to create/use a src directory for python codes as needed (maybe for organizing files and code), name it anything else but src as it is already created by Svelte for svelte files. Suggested name for directory backend.
For a working pywebview window, the very basic host.py code is
import webview
window = webview.create_window("Emergence", "build/index.html", width=1280, height=800)
webview.start()This is what the host.py contains as of the very first "Update README.md" commit.
A new npm command has been added npm run app that automatically builds the html and runs the python code to run the app. Default-ly use this to run every time.
This svelte app is build using the @sveltejs/adapter-static, to build a static html file. Pywebview simply hosting the index.html along with the folders and files inside build directory should be enough for now (problems may or may not be encountered in the future, will be resovlable anyway).
Sveltekit is a javascript
Everything you need to build a Svelte project, powered by sv.
If you're seeing this, you've probably already done this step. Congrats!
# create a new project in the current directory
npx sv create
# create a new project in my-app
npx sv create my-appOnce you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --openTo create a production version of your app:
npm run buildYou can preview the production build with npm run preview.
To deploy your app, you may need to install an adapter for your target environment.