Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run a custom script before ng serve and before live reload/ auto reload in angular 7?

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 ?

like image 527
leox Avatar asked Nov 12 '19 10:11

leox


People also ask

What happens when Ng serve command is executed?

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.

What is difference between NPM start and Ng serve?

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.

What command would you use to build and serve your app automatically opening a new browser window?

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.

Where do you execute ng serve?

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 .


1 Answers

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.

like image 82
cengiz sevimli Avatar answered Oct 22 '22 02:10

cengiz sevimli