Angular/Installation : Différence entre versions

De WikiSys
Aller à : navigation, rechercher
m (Houtisse a déplacé la page Angular/Tutorials/Installation vers Angular/Installation sans laisser de redirection)
(Workspace files)
Ligne 49 : Ligne 49 :
 
The top level of the workspace contains a number of workspace-wide configuration files.
 
The top level of the workspace contains a number of workspace-wide configuration files.
 
WORKSPACE CONFIG FILES PURPOSE
 
WORKSPACE CONFIG FILES PURPOSE
:.editorconfig Configuration for code editors. See EditorConfig.
+
;.editorconfig: Configuration for code editors. See EditorConfig.
:.gitignore Specifies intentionally untracked files that Git should ignore.
+
;.gitignore : Specifies intentionally untracked files that Git should ignore.
:angular.json CLI configuration defaults for all projects in the workspace, including configuration options for build, serve, and test tools that the CLI uses, such as :TSLint, Karma, and Protractor. For details, see Angular Workspace Configuration.
+
;angular.json: CLI configuration defaults for all projects in the workspace, including configuration options for build, serve, and test tools that the CLI uses, such as :TSLint, Karma, and Protractor. For details, see Angular Workspace Configuration.
:node_modules Provides npm packages to the entire workspace.
+
;node_modules : Provides npm packages to the entire workspace.
:package.json Configures npm package dependencies that are available to all projects in the workspace. See npm documentation for the specific format and contents of this file.
+
;package.json : Configures npm package dependencies that are available to all projects in the workspace. See npm documentation for the specific format and contents of this file.
:package-lock.json Provides version information for all packages installed into node_modules by the npm client. See npm documentation for details. If you use the yarn client, this file will be yarn.lock instead.
+
;package-lock.json: Provides version information for all packages installed into node_modules by the npm client. See npm documentation for details. If you use the yarn client, this file will be yarn.lock instead.
:tsconfig.json Default TypeScript configuration for apps in the workspace, including TypeScript and Angular template compiler options. See TypeScript Configuration.
+
;tsconfig.json : Default TypeScript configuration for apps in the workspace, including TypeScript and Angular template compiler options. See TypeScript Configuration.
:tslint.json Default TSLint configuration for apps in the workspace.
+
;tslint.json : Default TSLint configuration for apps in the workspace.
:README.md Introductory documentation.
+
;README.md : Introductory documentation.
  
  
Ligne 85 : Ligne 85 :
 
</pre>
 
</pre>
 
----
 
----
 +
 
== node_modules ==
 
== node_modules ==
 
* https://stackoverflow.com/questions/34526844/what-is-node-modules-directory-in-angularjs
 
* https://stackoverflow.com/questions/34526844/what-is-node-modules-directory-in-angularjs

Version du 24 mai 2019 à 17:11

Step 1: Install the Angular CLI

 su
 npm install -g @angular/cli

Step 2: Create a workspace and initial application

To create a new workspace and initial app project:

 ng new propositions
 CSS

Step 3: Serve the application

 cd ~/Angular/propositions
 ng serve --open
 http://localhost:4200/

Step 4: Edit your first Angular component

emacs src/app/app.component.ts
title = 'Propositions Network';
emacs src/app/app.component.css
     
h1 {
  color: #369;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 250%;
}


Workspace and project file structure

You develop apps in the context of an Angular workspace. A workspace contains the files for one or more projects. A project is the set of files that comprise a standalone app, a library, or a set of end-to-end (e2e) tests.

The Angular CLI command ng new <project_name> gets you started. When you run this command, the CLI installs the necessary Angular npm packages and other dependencies in a new workspace, with a root folder named project_name. It also creates the following workspace and starter project files:

  • An initial skeleton app project, also called project_name (in the src/ subfolder).
  • An end-to-end test project (in the e2e/ subfolder).
  • Related configuration files.

The initial app project contains a simple Welcome app, ready to run

Workspace files

The top level of the workspace contains a number of workspace-wide configuration files. WORKSPACE CONFIG FILES PURPOSE

.editorconfig
Configuration for code editors. See EditorConfig.
.gitignore 
Specifies intentionally untracked files that Git should ignore.
angular.json
CLI configuration defaults for all projects in the workspace, including configuration options for build, serve, and test tools that the CLI uses, such as :TSLint, Karma, and Protractor. For details, see Angular Workspace Configuration.
node_modules 
Provides npm packages to the entire workspace.
package.json 
Configures npm package dependencies that are available to all projects in the workspace. See npm documentation for the specific format and contents of this file.
package-lock.json
Provides version information for all packages installed into node_modules by the npm client. See npm documentation for details. If you use the yarn client, this file will be yarn.lock instead.
tsconfig.json 
Default TypeScript configuration for apps in the workspace, including TypeScript and Angular template compiler options. See TypeScript Configuration.
tslint.json 
Default TSLint configuration for apps in the workspace.
README.md 
Introductory documentation.


angular.json

Bootstrap 
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/mon-projet-angular",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
              "styles": [
		  "./node_modules/bootstrap/dist/css/bootstrap.css",
		  "src/styles.scss"
            ],
            "scripts": [],
            "es5BrowserSupport": true
          },

node_modules

The node_modules directory is only for build tools.

The package.json file in the app root defines what libraries will be installed into node_modules when you run npm install

Very often with an angular app, on your dev machine or on a build server, you use other Javascript libraries from npm (a node.js package manager) to build your angular app. Tasks can be concatenating resources, using CSS preprocessors like LESS or SASS, minification, replacing of values, etc. etc. The most common tools for managing and running these tasks are called grunt and gulp, which are installed through npm as well.

When you deploy your app, you only distribute the resulting build, not any of the source files or build tools.

It is of course possible to write an AngularJS app without building anything.

edit from comments: When you dive into Angular more, there are more advanced techniques of using libraries installed by npm even in the client app, you then selectively choose the ones you need, not the whole 50MB+ thing. I'd recommend staying with the basic approaches until you get a good grasp on them though.