The bare minimum boilerplate to use svelte in electron
npm start
to build, bundle, and watch the svelte app, then load it as renderer thread in an electon app.
Use ES6 import
. The modules will be bundled.
// you can import from relative path
import MyComponent from './MyComponent.svelte';
import { myUtilFunc } from './MyUtilFunc';
// or from node modules
import { writable } from 'svelte/store';
Use CommonJS require()
. The modules will NOT be bundled. The import will be resolved at runtime.
const app = require('electron').remote.app;
const path = require('path');
const fs = require('fs');
// DON'T do this. It will NOT be bundled!
const { writable } = require('svelte/store');