|
1 |
| -# NgImmutableExample |
2 |
| - |
3 |
| -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.3. |
4 |
| - |
5 |
| -## Development server |
6 |
| - |
7 |
| -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. |
8 |
| - |
9 |
| -## Code scaffolding |
10 |
| - |
11 |
| -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. |
12 |
| - |
13 |
| -## Build |
14 |
| - |
15 |
| -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. |
16 |
| - |
17 |
| -## Running unit tests |
18 |
| - |
19 |
| -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). |
20 |
| - |
21 |
| -## Running end-to-end tests |
22 |
| - |
23 |
| -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). |
24 |
| - |
25 |
| -## Further help |
26 |
| - |
27 |
| -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
| 1 | +<h1>unpkg-immutable-example</h1> |
| 2 | +<h2>Hosting an <a href="https://immutablewebapps.org">Immutable Web App</a> with <a href="https://www.npmjs.com/">npm</a>, |
| 3 | +<a href="https://unpkg.com/#/">UNPKG</a>, and <a href="https://pages.github.com/">GitHub Pages</a></h2> |
| 4 | +<p>Immutable Web Apps are composed of two concepts:</p> |
| 5 | +<ul> |
| 6 | +<li><b>Immutable Assets:</b> Static assets (javascript, CSS, images) that are hosted at a permanent, versioned, |
| 7 | + long-term browser cached location and that do not contain any environment-specific configuration.</li> |
| 8 | +<br /> |
| 9 | +<li><b>Deployment Manifest:</b> An <code>index.html</code> that is unique to the environment and not cached by the |
| 10 | + browser. It contains environment-specific configuration, references to the versioned immutable assets, and meta |
| 11 | + data.</li> |
| 12 | +</ul> |
| 13 | +<p>Using a combination of npm, UNPKG, and Github Pages covers nearly all of these requirements!</p> |
| 14 | +<ul> |
| 15 | +<li><b><a href="https://www.npmjs.com/">npm</a>:</b> The software registry stores the the static assets in |
| 16 | + versioned, immutable packages.</li> |
| 17 | +<br /> |
| 18 | +<li><b><a href="https://unpkg.com/#/">UNPKG</a>:</b> The CDN makes all assets of the package on npm addressable |
| 19 | + over https |
| 20 | + and globally available.</li> |
| 21 | +<br /> |
| 22 | +<li><b><a href="https://pages.github.com/">GitHub Pages</a>:</b> This static hosting site supports easy |
| 23 | + configuration of DNS and Certificates, has great integration with GitHub (obviously), and has a short TTL for |
| 24 | + browser caching</li> |
| 25 | +</ul> |
| 26 | +<h2><i>This site is hosted using npm, UNPKG, and GitHub Pages!</i></h2> |
| 27 | +<h3>Project Structure</h3> |
| 28 | +<p>The git repository <a href="https://github.com/ImmutableWebApps/unpkg-immutable-example">unpkg-immutable-example</a> |
| 29 | +is split into two critical branches: |
| 30 | +<ul> |
| 31 | + <li><a href="https://github.com/ImmutableWebApps/unpkg-immutable-example/tree/default"><code>default</code></a> |
| 32 | + is where the Angular project is maintained. It was generated from Angular CLI and is generally maintained like |
| 33 | + any other static web application.</li> |
| 34 | + <br /> |
| 35 | + <li><a href="https://github.com/ImmutableWebApps/unpkg-immutable-example/tree/master"><code>master</code></a> is |
| 36 | + configured to serve the GitHub Pages site. It only contains a single file <a href="https://github.com/ImmutableWebApps/unpkg-immutable-example/blob/master/404.html"><code>404.html</code></a>. |
| 37 | + This single file is served for every request made to the GitHub Pages site.</li> |
| 38 | +</ul> |
| 39 | +<h3>Project Lifecycle</h3> |
| 40 | +<h4>Building</h4> |
| 41 | +<p>Developing this web application is the same as any other. Features are built and tested locally, commits and |
| 42 | + pull requests advance the state of the codebase. When a stable version of the app is ready to be deployed, the |
| 43 | + assets are rendered to the <code>/dist</code> folder using <code>npm run build</code> and new version of the |
| 44 | + project is published to npm using <code>npm publish</code>. The assets become available on <a href="https://unpkg.com/@immutablewebapps/[email protected]/">UNPKG</a>.</p> |
| 45 | +<h4>Deploying</h4> |
| 46 | +<p>With the new version of the assets available on UNPKG, we can trigger an <i>atomic</i> deployment by |
| 47 | + switching to the <code>master</code> branch and updating <code>404.html</code> with the new references to project |
| 48 | + assets via UNPKG as well as any related changes to environment variables. Once the commit is made, GitHub Pages |
| 49 | + deployment is triggered and the new version of the web application is available.</p> |
| 50 | +<h4>Deploying to Another Environment</h4> |
| 51 | +<p>Setup another <a href="https://github.com/ImmutableWebApps/unpkg-immutable-deployment">Github Pages repository</a>, |
| 52 | + add a <a href="https://github.com/ImmutableWebApps/unpkg-immutable-deployment/blob/master/404.html"><code>404.html</code></a>, |
| 53 | + and <a href="https://immutablewebapps.org/unpkg-immutable-deployment/">another deployment of the app</a> is |
| 54 | + created!</p> |
0 commit comments