-
Notifications
You must be signed in to change notification settings - Fork 0
Angular Project Orchestration
- Important: Please do not skip steps when creating a new Angular project
- When creating a new project always use the Angular CLI tool (
ng
)- if already installed verify that it is in version ^8.2.x with
ng -v
(from angular ^9.x,ng v
has to be used instead)
- if already installed verify that it is in version ^8.2.x with
- generate a new project with
ng new {{customer-project}} --style=scss --prefix={{prefix}} --routing=true
-
{{customer-project}}
is pair of customer name and project name, for example:kvasar-permweb
,kiwi-kapla
orflowup-web
- sometimes there needs to be added a frontend suffix like
customer-project-fe
- sometimes there needs to be added a frontend suffix like
-
--style=scss
will set default style to SCSS -
{{prefix}}
will represent application prefix, in most of the existing projects we have the defaultapp
prefix, however, the best prefix is something that will identify projects components (name of the project or customer, alternatively a combination of customer and project initials)
-
- run
npm audit fix --all
to audit and update packages with vulnerabilities - run
npm install @angular/language-service --save-dev
to activate Angular language service support in WebStorm (or other supported IDE) - copypaste these additional useful files to the project's root
add the following to angular.json's architect.build.options
property:
"stylePreprocessorOptions": {
"includePaths": [
"src"
]
},
- thanks to including paths
"."
you should be able to import SCSS files with relative pathnames
@import 'variables'; // style located at src/
@import '~@angular/material/prebuilt-themes/indigo-pink.css'; // style from node_modules
put this style to your style.scss
in src
/** WARNING: Do NOT import this file in any component style */
html,
body {
height: 100%;
}
body {
line-height: 1;
}
* {
margin: 0;
padding: 0;
outline: none;
box-sizing: border-box;
}
/* stylelint-disable-next-line selector-max-type */
input,
button {
border: none;
background: none;
}
- run
npm install tslint-immutable --save-dev
to install tslint-immutable
- run
npm i --save-dev rxjs-tslint
put tslint.json into the project root
- run
ng lint --fix
orng-lint {{project-source-code}} --fix
if it fails because of multiple projects (e2e)
note do not forget to change the component prefix rule to match the project
note you might need to resolve some errors in generated files, these are some of them:
Click to expand!
- methods return types in
app.po.ts
import { browser, by, element } from 'protractor';
import { promise as wdpromise } from 'selenium-webdriver';
export class /* CLI generated class name */ {
navigateTo(): wdpromise.Promise<any> {
return browser.get('/');
}
getParagraphText(): Promise<string> {
return element(by.css(/* css selector (for example 'app-root h1') */)).getText();
}
}
- karma loaded function in
test.ts
declare const __karma__: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function(): any {
/* useless but needed comment */
};
- rewrite console.log to console.info
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.info(err));
- add compiler option to
tsconfig.json
in project's root
"compilerOptions": {
...
"forceConsistentCasingInFileNames": true,
"newLine": "LF",
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
...
}
put .stylelintrc.json into the project root for "stylelint": "^8.2.0"
run npm install stylelint --save-dev
add this line in package.json
For basic HTML linting add .htmlhintrc into the project root, run npm install htmlhint --save-dev
and add the following line to package.json
:
"lint": "npm run lint:ts && npm run lint:html && npm run lint:scss",
"lint:ts": "npx ng lint",
"lint:html": "npx htmlhint 'src/**/*.html'",
"lint:scss": "npx stylelint 'src/**/*.scss'",
Add Prettier as described here
- Integrate this collection of useful GIT hooks Angular GIT hooks
Add this in angular.json
to the schematics
inside the @schematics/angular:component
"changeDetection": "OnPush",
- if project will use NGRX for state management, run
ng add @ngrx/store
,ng add @ngrx/store-devtools
,ng add @ngrx/effects
,ng add @ngrx/entity
. Addingentity
might show error about not supporting schematics, it is not a problem.
- if the project will use material design, run
ng add @angular/material
-
FE / Angular
-
Golang
-
DevOps
-
Agile process and SCRUM
-
Internship
-
Bootcamp