Angular, e-reloading, e-reloading Webpack

Summary:

I am trying to create an electron and angular app that uses electronic reload and webpack for live reload. In my package.json file I create angular and then run electron which starts the main process and angular boot files. To start the application, I run the commands: npm start

and npm run electron

, one by one, in separate terminals.

Problem:

The app loads correctly; however, when I add a change to the file, the electronic part of my application remains intact, but a part of my angular application is lost. Please, help.

package.json

{
  "scripts": {
    ...
    "start": "webpack --watch ",
    ...
    "build-electron": "ng build --base-href .  && tsc src\\electron\\electron-main.ts --outDir dist && tsc src\\electron\\logger.ts --outDir dist && tsc src\\electron\\application-menu.ts --outDir dist && copy src\\electron\\package.json dist  && copy src\\electron\\*.html dist",
    "electron": "npm run build-electron && electron ./dist --serve"
  },
  ...
}

      

File structure

Folder PATH listing for volume Windows
Volume serial number is 000000B3 D831:A351
C:.
|   .angular-cli.json
|   .editorconfig
|   .gitattributes
|   .gitignore
|   karma.conf.js
|   package.json
|   protractor.conf.js
|   README.md
|   tree.txt
|   tsconfig.json
|   tslint.json
|   webpack.config.js
|   WinstonLogging.log
|   
+---dist
|   |   application-menu.js
|   |   electron-main.js
|   |   favicon.ico
|   |   index.html
|   |   inline.bundle.js
|   |   inline.bundle.js.map
|   |   invalid.html
|   |   loading.html
|   |   logger.js
|   |   main.bundle.js
|   |   main.bundle.js.map
|   |   package.json
|   |   polyfills.bundle.js
|   |   polyfills.bundle.js.map
|   |   preferences.html
|   |   styles.bundle.js
|   |   styles.bundle.js.map
|   |   vendor.bundle.js
|   |   vendor.bundle.js.map
|   |   
|   \---assets
|           default.gif
|           quest_logo.png
|           spinner.gif
|           
... <node modules and e2e>
\---src
    |   favicon.ico
    |   index.html
    |   main.ts
    |   polyfills.ts
    |   styles.scss
    |   test.ts
    |   tsconfig.app.json
    |   tsconfig.spec.json
    |   typings.d.ts
    |   
    +---app
    |   |   app-routing.module.ts
    |   |   app.component.html
    |   |   app.component.scss
    |   |   app.component.spec.ts
    |   |   app.component.ts
    |   |   app.module.ts
    |   |   
    |   \---components
    |       +---home
    |       |       home.component.html
    |       |       home.component.scss
    |       |       home.component.spec.ts
    |       |       home.component.ts
    |       |       
    |       \---preferences
    |               preferences.component.html
    |               preferences.component.scss
    |               preferences.component.spec.ts
    |               preferences.component.ts
    |               
    +---assets
    |       .gitkeep
    |       default.gif
    |       spinner.gif
    |       
    +---electron
    |       application-menu.js
    |       application-menu.ts
    |       electron-main.ts
    |       invalid.html
    |       loading.html
    |       logger.ts
    |       package.json
    |       preferences.html
    |       
    \---environments
            environment.prod.ts
            environment.ts

      

+3


source to share


1 answer


Run ng serve in one terminal and modify the main.js file.

win.loadURL('http://localhost:4200/index.html');

      



then run npm run electron in another terminal

0


source







All Articles