Open jackusay opened 3 years ago
I am in the same place as you, no idea how to package my app into .exe file. Shipping the source code is probably the correct way to ship the app as per QT license but is arguably not user friendly (my audience is people without technical knowledge). The way I wanted to resolve this is by letting them use .exe and download the source if they have to for whatever reason.
I'm in the same boat. Can't build for Windows at all.
Currently the README page does not mention it, but the "dist" folder content is make with webpack, so you must add it as a dev dependency. Webpack pack index.js in a .node file but some content can't be packed directly so need of plugins to be packed, so those need to be installed too.
The plugins used in the starter repo are ts-loader (for typescript), file-loader (for images) and native-addon-loader (for nodejs), to make them work, you will need a webpack.config.js file that will be in the root folder of your project.
In my particular case the webpack.config.js settings from the starter repo was not useful, i don't use typescript and native-addon+ file-loader were giving me two .node files that weren't working, so i ended up doing a different settings by using native-ext-loader since native-addon was hard to configure alone o_o, anyway, i will leave it here in case someone find it useful.
const path = require("path");
module.exports = {
mode: process.NODE_ENV || "development",
entry: "./src",
target: "node",
output: {
path: path.resolve(__dirname, "dist"),
filename: "index.js"
},
module: {
rules: [
{
test: /\.node$/,
use: [
{
loader: "native-ext-loader"
}
]
}
]
},
};
You should build a dist directory before packing it:
npm run build
- build via webpack your app into dist dir with .js and .node filesnpx nodegui-packer --init MyApp
- creates deploy dir with some meta files.npx nodegui-packer --pack ./dist
- packed app into .exe file if you are using windows platform.
And your .exe app will be placed in path/to/app/deploy/win32/build
How to use this tool?
simplest
package.json
:all my code is a
index.js
:npx nodegui-packer --init MyAppName
#generatedisplay
folder. I don't touch anything inside.create a
dist
folder, then put all my code (just aindex.js
file) into this folder.npx nodegui-packer --pack ./dist
result:
relative: https://github.com/nodegui/packer/issues/112
...and I find out electron's doc is more user friendly to a newbie...