I have to run a custom script before the starting the ng serve command from angular cli and before angular live reload/auto reload? Is it possible with angular 7+ other than modifying the package.json ?
ng serve command builds and serve the application. It rebuilds the application if changes occur. Here project is the name of the application as defined in angular.
npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server. js. It seems like ng serve starts the embedded server whereas npm start starts the Node servers.
In your browser, open http://localhost:4200/ to see the new application run. When you use the ng serve command to build an application and serve it locally, the server automatically rebuilds the application and reloads the page when you change any of the source files.
ng serve. To get the application running, the ng serve command must execute within the [name-of-app] folder. Anywhere within the folder will do. The Angular CLI must recognize that it is within an environment generated with ng new .
Find your package.json
and add the following:
"start": "customScript && ng serve"
.
Then use npm run start
Other solutions than this would be based on tricking the system and CLI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With