karolis-sh / electron-snowpack

Use Snowpack and esbuild for Electron app development
MIT License
50 stars 8 forks source link

"npm run dev" works in examples, but not "npm run dist" #39

Closed abrighton closed 3 years ago

abrighton commented 3 years ago

Thanks for the examples. When I run "npm run dist" in the react-typescript example, the generated app opens an empty window, even though "npm run dev" displays the app as expected. I got the same issue on both linux and mac. Any ideas? Thanks

karolis-sh commented 3 years ago

Not sure about npm, but with yarn it seems to run just fine with yarn try (on mac) on this monorepo. Though I noticed that there's some randomness with all examples one the open command running right after electron-builder - I sometimes get some obscure errors and can't open.

There's not enough info for me to understand what and where you're executing commands, but I suspect it's got something to do with electron-builder usage.

abrighton commented 3 years ago

Thanks. I guess the main problem was that I didn't run "yarn build" before running "yarn dist". Now it is working. I changed my version of the package.json scripts section to support Linux and Mac:

  "scripts": {
    "build": "electron-snowpack build",
    "clean": "electron-snowpack clean",
    "dev": "electron-snowpack dev",
    "dist": "electron-builder",
    "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
    "openMac": "open dist/mac/${npm_package_name}.app",
    "openLinux": "dist/linux-unpacked/${npm_package_name}",
    "tryMac": "run-s clean build dist:dir openMac",
    "tryLinux": "run-s clean build dist:dir openLinux",
    "postinstall": "electron-builder install-app-deps"
  },

I probably need to work on the options to dist:dir to work for linux. For now I just installed the snap with 'sudo snap install --dangerous dist/...'.

For my app, I also needed to add "allowSyntheticDefaultImports" to compilerOptions in tsconfig.json.