Build & Release
Angular workspace
angular.json defines two projects:
|
The application. Targets: |
|
Protractor end-to-end scaffolding. Targets: |
|
|
Build configurations: production, development, swtest, test2.
npm scripts
|
Generate |
|
Generate |
|
Dev server with |
|
Development build. |
|
|
|
Production build without |
|
Build with the |
|
Build with |
|
Production build plus |
|
Analyzer against an existing |
|
Karma in watch mode. |
|
|
|
Headless Karma, no coverage (the pre-push hook). |
|
ESLint variants. |
|
Prettier over |
|
|
|
Cypress runner. |
|
Every Angular CLI script in |
CodeBuild pipeline
buildspec.yaml:
env:
variables:
PYB_IAC_AWS_DEFAULT_REGION: 'us-east-1'
secrets-manager:
NPM_TOKEN: aws-codebuild-token-eva
phases:
install:
runtime-versions: { nodejs: 12, python: 3.8 }
commands:
- export CHROME_BIN=/usr/bin/chromium-browser
- echo "//npm.pkg.github.com/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc
- echo "@payability:registry=https://npm.pkg.github.com/" >> ~/.npmrc
- npm install
- npm install -g @angular/cli
pre_build:
commands:
- npm run pre-build
# - npm run test:ci (1)
build:
commands:
- |
if [ $ENV_NAME = "prod" ] || [ $ENV_NAME = "staging" ] ; then
npm run build:prod
else
npm run build
fi
artifacts:
files: ./**/*
name: pyb-ng2-sd-build
base-directory: dist
| 1 | The test step is commented out. CI does not currently run the unit suite — the only automated gate is the Husky pre-push hook on a developer’s machine. |
|
Selects the backend environment. |
|
Selects the domain and config profile. |
|
Pulled from Secrets Manager to authenticate against GitHub Packages. |
|
Set for Karma, even though the test step is disabled. |
Artifact |
The contents of |
|
|
Version stamping
config/pre-build.js writes three provenance fields into environment.ts:
|
From |
|
|
|
The |
They are surfaced in the UI footer, so a screenshot identifies the exact build.
Bumping the app version means editing package.json and adding a CHANGELOG.md
entry.
Service worker
Registered only in production:
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: environment.production,
registrationStrategy: 'registerImmediately',
})
ngsw-config.json asset groups:
| Group | Install mode | Resources |
|---|---|---|
|
|
|
|
|
|
|
|
Plus data groups for themes.
ServiceWorkerService watches for a new version and prompts a reload through the
update-app-banner component.
Use npm run build:swtest to build with service-worker behaviour enabled outside
production.
PWA
src/manifest.webmanifest declares the installable app.
modals/pwa-ios-install-modal/ gives iOS users add-to-home-screen instructions,
since iOS has no install prompt.
Bundle analysis
$ npm run analyze # build + open the analyzer
$ npm run build:stats # just produce dist/stats.json
$ npm run bundle-report # analyze an existing stats.json
source-map-explorer is also available as a dependency.
Every feature module is lazy-loaded, so a large initial bundle usually means
something eagerly imported a feature module — check AppModule and
PartialsModule first.
Git hooks
Installed by the postinstall script (husky install).
pre-commit |
|
pre-push |
|
|
Since CI does not run tests, the pre-push hook is the only automated test gate.
Bypassing it with |