Electron A desktop cross platform framework. In order to be able to use TypeScript for development, so the integration of configuration
- To create an Angular2 project
ng new ang-electron2
*cd enters the project file after creation
npm install electron --save-dev --save-exact
- In the project, we need to Electron description Make changes to the following file, where main.js is the file you need to create.
We write the following code to main.js
Note: we need to modify the < base href = "/" > in the index.html file and replace it with < base href = ". /" >
Modify the package.json file to add the relevant configuration of electron. The added content is marked with red circle. (note that the misspelling in front of my word leads to the use of electorn to run the project.)
Running the project
npm run electron # According to the method name you wrote, I wrote electorn in the screenshot, then my command will become npm run electorn
Running effect, it can be found that the debugging mode is automatically turned on. If you want to turn off debugging mode, comment out win.webContents.openDevTools() in main.js and compile again.