Skip to content
Permalink
Browse files

refactor: prettier --config ./.prettierrc --list-different \"src/{app…

…,environments,styles}/**/*{.ts,.json,.scss}\"
  • Loading branch information...
Gorniv committed Oct 17, 2018
1 parent 142e978 commit 4cf528eae2a1ed0e3e994b5d8d5c3cf751aed9ca
Showing with 315 additions and 89 deletions.
  1. +30 −3 .prettierrc
  2. +185 −0 package-lock.json
  3. +2 −0 package.json
  4. +38 −32 prerender.ts
  5. +29 −19 server.ts
  6. +6 −6 src/app/app.browser.module.ts
  7. +1 −5 src/app/app.component.ts
  8. +1 −2 src/app/app.module.ts
  9. +14 −5 src/app/app.routing.ts
  10. +3 −1 src/main.browser.ts
  11. +1 −6 src/polyfills.ts
  12. +1 −1 src/styles/main.scss
  13. +3 −6 src/test.ts
  14. +1 −3 static.paths.ts
@@ -1,9 +1,36 @@
{
"printWidth": 100,
"parser": "typescript",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"prettier-tslint": true,
"arrowParens": "always"
"arrowParens": "always",
"overrides": [
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
},
{
"files": "*.json",
"options": {
"parser": "json",
"trailingComma": "none"
}
},
{
"files": "*.scss",
"options": {
"parser": "scss",
"trailingComma": "none"
}
},
{
"files": "*.css",
"options": {
"parser": "css",
"trailingComma": "none"
}
}
]
}

Some generated files are not rendered by default. Learn more.

@@ -11,6 +11,7 @@
"ssr:sw": "ng run universal-demo:server:dev --watch",
"ssr:webpack": "webpack --watch",
"ssr:server": "nodemon server.js",
"format:check": "prettier --config ./.prettierrc --list-different \"src/{app,environments,styles}/**/*{.ts,.json,.scss}\"",
"build": "ng build",
"build:server": "ng run universal-demo:server:production",
"build:prod": "ng build --prod",
@@ -69,6 +70,7 @@
"karma-jasmine": "1.1.2",
"karma-jasmine-html-reporter": "1.3.1",
"nodemon": "1.18.3",
"prettier-tslint": "^0.4.0",
"protractor": "5.4.0",
"ssri": "6.0.0",
"tslint": "5.11.0",
@@ -9,12 +9,12 @@ const files = fs.readdirSync(`${process.cwd()}/dist-server`);

global['window'] = win;
Object.defineProperty(win.document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true
};
},
value: () => {
return {
enumerable: true,
configurable: true,
};
},
});
global['document'] = win.document;
global['CSS'] = null;
@@ -39,7 +39,7 @@ import { renderModuleFactory } from '@angular/platform-server';
import { ROUTES } from './static.paths';

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const mainFiles = files.filter(file => file.startsWith('main'));
const mainFiles = files.filter((file) => file.startsWith('main'));
const hash = mainFiles[0].split('.')[1];
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require(`./dist-server/main.${hash}`);
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
@@ -52,34 +52,40 @@ const index = readFileSync(join('dist', 'index.html'), 'utf8');
let previousRender = Promise.resolve();

// Iterate each route path
ROUTES.forEach(route => {
const fullPath = join(BROWSER_FOLDER, route);
ROUTES.forEach((route) => {
const fullPath = join(BROWSER_FOLDER, route);

// Make sure the directory structure is there
if (!existsSync(fullPath)) {
let syncpath = BROWSER_FOLDER;
route.split('/').forEach(element => {
syncpath = syncpath + '/' + element;
mkdirSync(syncpath);
});
}
// Make sure the directory structure is there
if (!existsSync(fullPath)) {
let syncpath = BROWSER_FOLDER;
route.split('/').forEach((element) => {
syncpath = syncpath + '/' + element;
mkdirSync(syncpath);
});
}

// Writes rendered HTML to index.html, replacing the file if it already exists.
previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
// Writes rendered HTML to index.html, replacing the file if it already exists.
previousRender = previousRender
.then((_) =>
renderModuleFactory(AppServerModuleNgFactory, {
document: index,
url: route,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{
provide: REQUEST, useValue: null
},
{
provide: RESPONSE, useValue: null
},
{
provide: 'ORIGIN_URL',
useValue: environment.host
}
]
})).then(html => writeFileSync(join(fullPath, 'index.html'), html));
provideModuleMap(LAZY_MODULE_MAP),
{
provide: REQUEST,
useValue: null,
},
{
provide: RESPONSE,
useValue: null,
},
{
provide: 'ORIGIN_URL',
useValue: environment.host,
},
],
}),
)
.then((html) => writeFileSync(join(fullPath, 'index.html'), html));
});

0 comments on commit 4cf528e

Please sign in to comment.
You can’t perform that action at this time.