Is there any way to use html file as entry point when render to Desktop APP?
armqtt opened this issue · 2 comments
Long time ago, I had written a static html web page using jquery that want to become a Desktop APP.
When I render to app, electron always use {project-folder}/src/renderer/index.js as entry point. However, my expected output is to use the index.html as entry point when I am render to win exe, mac app and linux deb.
I try many times when I am using npm run dev that exactly use index.html as entry point. But, when I use npm run build, it always use {project-folder}/src/renderer/index.js as entry point. How to solve it?
Here my package.json:
{
"name": "cj-typing",
"version": "1.0.0",
"license": "MIT",
"author": "",
"main": "index.js",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"build": "electron-webpack && electron-builder",
},
"development": {
"build": {
"appId": "cj-typing",
"category": "app.category.productivity",
"win": {
"target": [
"portable"
]
}
}
},
"dependencies": {
"jquery": "^3.5.1",
"jquery-mobile": "^1.5.0-alpha.1",
"source-map-support": "^0.5.16"
},
"devDependencies": {
"electron": "^11.3.0",
"electron-builder": "^22.9.1",
"electron-debug": "^3.2.0",
"electron-webpack": "^2.8.2",
"html-webpack-plugin": "^5.2.0",
"webpack": "~4.42.1"
}
}
My {project-folder}/src/renderer/index.js
import css from './css.html';
document.getElementsByTagName('head').innerHTML += css;
import content from './content.html';
document.getElementById("app").innerHTML = content;
My {project-folder}/src/main/index.js
window.loadURL(formatUrl({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file',
slashes: true
}))
I am also curious on that
I was able to do this by adding the following to my package.json
"electronWebpack": {
"renderer": {
"template": "src/renderer/index.html"
}
}
Found it in the docs.
https://webpack.electron.build/configuration