1. What is Angular CLI?
The Angular CLI is a command-line interface tool
that you use to initialize, develop, scaffold, and maintain Angular
applications directly from a command shell.
It is installed using the npm
package manager :
npm
install -g @angular/cli
2. The difference
between npm install vs npm install –g?
npm install without the -g
installs the specified package to the package cache of the package in the
current directory. This requires you to be in the directory of a package, a
directory containing a package.json
file.
npm
install -g
install the specified package to a global package
cache. This may be performed from any directory; and will make the installed
package's executables available from anywhere on your system.
Simply, without -g
packages are installed in local app folder. When installed with -g it gets
installed globally.
3.What does ng serve
do?
Ng serve builds and
serves your app, rebuilding on file changes.
It’s Syntax is :
ng serve
<project> [options]
ng s <project>
[options]
Here <project>
is argument and it is name of the project to build.
Can be an application or a library.
Basically, when ng serve is executed (run) the server starts listening for requests and processing
the ones it receives. it sets up the HTTP or HTTPS listener based on your configuration
variables and options.
ng serve can also
rebuild in real time, meaning if you change an angular file while it’s running
it will rebuild the code base and serve the rebuilt code immediately on next
refresh or next call to the listener.
4.What is the importance of SRC and E2E folder?
The key benefits of an end to end testing are listed below:
- End to end testing tests the complete flow or the action. For example, a complete login process can be treated as one end to end testing. Basically, it tests a specific functionality.
- It doesn’t improve the code quality as does in Unit testing. Unit testing is a different topic, and an end to end testing and unit testing are completely different.
- An
end to end testing run tests on the browser, so it tests your application live,
with some real data.
And the key benefits of src/ folder are as below:
- The src stands for source.
- The /src folder comprises of the raw non-minified code.
- The /src folder is used to store the file with the primary purpose of reading (and/or editing) the code.
- The /src folder contains all the sources, i.e. the code which is required to be manipulated before it can be used.
- Depending on the project, the /src folder may contain only the pure sources, or the non-minified versions.
So, the /src folder is primarily used to store the
source code files before any minification.
5. What are the differences between ng serve vs ng
build?
Both commands ng build and ng serve will clear the
output folder before they build the project.
But main difference is :
ng serve |
ng build |
ng serve command builds the angular application in the memory, without
saving the artifacts to any external folder and runs the application on
the web server. |
ng build command builds the angular application and generates the build artifacts which are saved under the /dist folder in the application directory. |
It means the ng serve
command is intentionally for fast, local and
iterative developments and also for builds, watches and serves the application
from a local CLI development server.
6. What does ng build –prod
flag?
ng build compiles an
Angular app into an output directory named dist/ at the given output path. It must
be executed from within a workspace directory.
It’s syntax is ,
ng build <project> [options]
ng
b <project> [options]
The application
builder uses the build tool, with default configuration options specified in
the workspace configuration file (angular.json
) or with a named alternative configuration.
A
"production" configuration is created by default when you use the CLI
to create the project, and you can use that configuration by specifying the --configuration="production"
or the --prod
option.
0 comments:
Post a Comment