From d84003db9e3ddab1c0de916c258187459e8475ac Mon Sep 17 00:00:00 2001 From: Enlcxx <8032887+Enlcxx@users.noreply.github.com> Date: Sun, 9 Dec 2018 18:20:57 -0500 Subject: [PATCH] load fonts for dev mode --- package.json | 3 ++- src/main.ts | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index b1df42056..3468e9a5f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "tools:typedoc": "yarn typedoc --mode modules --json dist/docs.json --tsconfig tsconfig.td.json --excludePrivate --excludeProtected --excludeExternals", "tools:docs": "yarn tools:typedoc && node dist/tools/docs", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", - "bundlesizelimit": "rm -rf dist/bundle.js && cat dist/@alyle/ui/**/*.umd.min.js >> dist/bundle.js && yarn bundlesize -f dist/bundle.js -c false -s '200 KB'" + "bundlesizelimit": "rm -rf dist/bundle.js && cat dist/@alyle/ui/**/*.umd.min.js >> dist/bundle.js && yarn bundlesize -f dist/bundle.js -c false -s '200 KB'", + "serve:lib": "hs src/app -p 1212 -g --cors 'Access-Control-Allow-Origin'" }, "private": true, "dependencies": { diff --git a/src/main.ts b/src/main.ts index d23d72d31..2f492c33f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,15 +14,19 @@ if (environment.production) { const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule); -// document.addEventListener('DOMContentLoaded', () => { - if (environment.hmr) { - if (module[ 'hot' ]) { - hmrBootstrap(module, bootstrap); - } else { - console.error('HMR is not enabled for webpack-dev-server!'); - console.log('Are you using the --hmr flag for ng serve?'); - } +if (environment.hmr) { + if (module[ 'hot' ]) { + hmrBootstrap(module, bootstrap); } else { - bootstrap(); + console.error('HMR is not enabled for webpack-dev-server!'); + console.log('Are you using the --hmr flag for ng serve?'); } -// }); +} else { + if (!environment.production) { + const style = window.document.createElement('link'); + style.setAttribute('href', 'http://localhost:10009/fonts.css'); + style.setAttribute('rel', 'stylesheet'); + window.document.head.appendChild(style); + } + bootstrap(); +}