Giter Club home page Giter Club logo

ng-iso's Introduction

NgIso

Angular Universal PWA Starter built with Angular Cli on Expressjs.

Assumptions

  • 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.

Files that require changes for a fresh project

  • webpack.config.js change the output path from '../ng-iso-deploy' to your-project-name-deploy
  • package.json
    • script copy-frontend-to-deploy-folder & push-dist-to-github & serverLocal change any mentions of ng-iso to your project name.
  • /src/app/app.common.module.ts {appId: 'ng-iso'}

Useful Commands

  • 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.

Build Scripts Explained

  • npm run deploy or npm 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 the webpack.config.js settings file into a single file: server.js and places it into your ng-iso-deploy folder.
    • 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"

creating deployment on digital ocean server:

updating deployment: ssh root@ipv4 address su - web cd /var/www/ sudo git pull origin master pm2 restart server

ng-iso's People

Contributors

ereckgordon avatar angular-cli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.