Angular Universal PWA Starter built with Angular Cli on Expressjs.
- angular cli (project generated with version 1.3.1)
- yarn (dependency management)
- angular 4.3+ (new httpClient)
- It is written for a windows machine, simple commands like copying (robocopy) and delete (del) would need to be replaced with os equivalent.
- You have another folder called ng-iso-deploy on the same level that you have ng-iso.
- ng-iso-deploy contains:a git repo, .gitignore, and .gitattributes. It is the deployment folder that you pull from to update the server.
- The various build scripts add server.js and the entire frontend dist folder to the ng-iso-deploy folder.
- webpack.config.js change the output path from
'../ng-iso-deploy'
toyour-project-name-deploy
- package.json
- script
copy-frontend-to-deploy-folder
&push-dist-to-github
&serverLocal
change any mentions ofng-iso
to your project name.
- script
- /src/app/app.common.module.ts
{appId: 'ng-iso'}
ng serve
- Run in frontend development mode on port 4200.npm run serverLocal
- Full build of frontend and backend, then serves frontend and backend on port 8000.npm run serverRebuild
- Rebuild and run server on port 8000, assumes no frontend changes.npm run deploy
- Build and push server & frontend assets to github deployment repo.npm run analyze
- Bundle analysis of non-tree shaken bundle. lets you see the individual angular module pieces.npm run analyze-deploy
- Bundle analysis of tree shaken bundle. kind of opaque, but truest to reality.yarn upgrade-interactive
- Upgrade only what you want to.
npm run deploy
ornpm run serverLocal
are idential, except deploy pushes to github, and serverLocal runs the local server on port 8000.- first it runs
prep
- first it runs
ng build prod --build-optimizer
to build the frontend production app. - second it runs
ng build --prod --app 1 --output-hashing none --build-optimizer
to build the server Aot Factory:AppServerModuleNgFactory
- third it runs
localWebpackForServer
which bundles the backend server from thewebpack.config.js
settings file into a single file:server.js
and places it into yourng-iso-deploy
folder.
- first it runs
- second it runs
copy-frontend-to-deploy-folder
which does just as it is named. - third it pushes the deploy folder to github with
push-dist-to-github
. You may want to have a more robust commit message than what I am currently using:"auto generated commit"
- first it runs
creating deployment on digital ocean server:
- sudo git remote add origin https://github.com/EreckGordon/ng-iso-deploy
- sudo git pull origin master
updating deployment:
ssh root@ipv4 address
su - web
cd /var/www/
sudo git pull origin master
pm2 restart server