Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to use html file as entry point when render to Desktop APP? #87

Open
armqtt opened this issue Feb 28, 2021 · 2 comments

Comments

@armqtt
Copy link

armqtt commented Feb 28, 2021

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
}))

@SpyrosMourelatos
Copy link

I am also curious on that

@benplain
Copy link

benplain commented Nov 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants