-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
212 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ filegroup( | |
name = "assets", | ||
srcs = glob([ | ||
"*.svg", | ||
"*.png", | ||
"**/*.png", | ||
"*.css", | ||
]), | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "Angular Bazel Example", | ||
"short_name": "Angular Bazel", | ||
"theme_color": "#43a047", | ||
"background_color": "#fff", | ||
"display": "standalone", | ||
"scope": "./", | ||
"start_url": "./", | ||
"icons": [ | ||
{ | ||
"src": "assets/icons/icon-72x72.png", | ||
"sizes": "72x72", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-96x96.png", | ||
"sizes": "96x96", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-128x128.png", | ||
"sizes": "128x128", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-144x144.png", | ||
"sizes": "144x144", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-152x152.png", | ||
"sizes": "152x152", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-384x384.png", | ||
"sizes": "384x384", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
}, | ||
{ | ||
"src": "assets/icons/icon-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png", | ||
"purpose": "maskable any" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "../node_modules/@angular/service-worker/config/schema.json", | ||
"index": "/index.html", | ||
"assetGroups": [ | ||
{ | ||
"name": "app", | ||
"installMode": "prefetch", | ||
"updateMode": "prefetch", | ||
"resources": { | ||
"files": [ | ||
"favicon.ico", | ||
"index.html", | ||
"manifest.webmanifest", | ||
"/**/*.css", | ||
"/**/*.js" | ||
], | ||
"urls": [ | ||
"https://fonts.googleapis.com/**", | ||
"https://fonts.gstatic.com/s/**" | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "assets", | ||
"installMode": "lazy", | ||
"updateMode": "prefetch", | ||
"resources": { | ||
"files": [ | ||
"/assets/**", | ||
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
User-agent: * | ||
Allow: / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,28 @@ | ||
///<reference types="node"/> | ||
import "zone.js/dist/zone-node"; | ||
///<reference types='node'/> | ||
import 'zone.js/dist/zone-node'; | ||
|
||
import { ngExpressEngine } from "@nguniversal/express-engine"; | ||
import * as express from "express"; | ||
import { join } from "path"; | ||
import { ngExpressEngine } from '@nguniversal/express-engine'; | ||
import * as express from 'express'; | ||
import { join } from 'path'; | ||
import * as compression from 'compression'; | ||
|
||
const app = express(); | ||
|
||
const PORT = process.env.PORT || 4000; | ||
const DIST_FOLDER = join(process.cwd(), "src/prodapp"); | ||
|
||
import { AppServerModule } from "./app/app.server.module"; | ||
|
||
app.engine( | ||
"html", | ||
ngExpressEngine({ | ||
bootstrap: AppServerModule, | ||
providers: [ | ||
// TODO add support for lazy loading with server side rendering | ||
// provideModuleMap(LAZY_MODULE_MAP) | ||
] | ||
}) as any | ||
); | ||
|
||
app.set("view engine", "html"); | ||
app.set("views", DIST_FOLDER); | ||
import { AppServerModule } from './app/app.server.module'; | ||
|
||
app.get("*.*", express.static(DIST_FOLDER, { maxAge: "1y" })); | ||
|
||
// catch /favicon.ico route to prevent the following server error: | ||
// Error: Cannot match any routes. URL Segment: 'favicon.ico' | ||
app.get("/favicon.ico", (req, res) => res.send("")); | ||
|
||
app.get("*", (req, res) => { | ||
res.render("example/index", { req }); | ||
}); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Node Express server listening on http://localhost:${PORT}`); | ||
}); | ||
const app = express(); | ||
const port = process.env.PORT || 4000; | ||
const DIST_FOLDER = join(process.cwd(), 'src/pwa'); | ||
|
||
/** | ||
* text compression for smaller download sizes and thus faster load times | ||
* without compression: 1.4 MB | ||
* with compresion: 321 kB | ||
*/ | ||
app.use(compression()); | ||
|
||
app.engine('html', ngExpressEngine({ bootstrap: AppServerModule }) as any); | ||
app.set('view engine', 'html'); | ||
app.set('views', DIST_FOLDER); | ||
|
||
app.get('*.*', express.static(DIST_FOLDER, { maxAge: '1y' })); | ||
app.get('*', (req, res) => res.render('example/index', { req })); | ||
app.listen(port, () => console.log(`Server listening http://localhost:${port}`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"Angular service worker support (credits: https://github.com/marcus-sa)" | ||
|
||
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") | ||
|
||
def ngsw_config(name, config, index_html, src, out = None, **kwargs): | ||
if not out: | ||
out = name | ||
|
||
ngsw_config_name = "%s_bin" % name | ||
|
||
nodejs_binary( | ||
name = ngsw_config_name, | ||
data = ["@npm//@angular/service-worker", index_html, config, src], | ||
visibility = ["//visibility:private"], | ||
entry_point = "@npm//:node_modules/@angular/service-worker/ngsw-config.js", | ||
) | ||
|
||
cmd = """ | ||
mkdir -p $@ | ||
cp -R $(locations {TMPL_src})/. $@/ | ||
cp $(location {TMPL_index}) $@/index.html | ||
$(location :{TMPL_bin}) $@ $(location {TMPL_conf}) | ||
""".format( | ||
TMPL_src = src, | ||
TMPL_bin = ngsw_config_name, | ||
TMPL_index = index_html, | ||
TMPL_conf = config, | ||
) | ||
|
||
native.genrule( | ||
name = name, | ||
outs = [out], | ||
srcs = [src, config, index_html], | ||
tools = [":" + ngsw_config_name], | ||
cmd = cmd, | ||
**kwargs | ||
) |
Oops, something went wrong.