Skip to content

Instantly share code, notes, and snippets.

View MarkPieszak's full-sized avatar
🐈
@ Trilon

Mark Pieszak MarkPieszak

🐈
@ Trilon
View GitHub Profile
@MarkPieszak
MarkPieszak / Angular Universal - Window service
Last active October 14, 2017 00:21
Angular Universal - Window service
// app.module.ts
export function win () {
return typeof window !== 'undefined' ? window : {};
}
// ... in the NgModule
{ provide: WindowService, useFactory: (win) }
@MarkPieszak
MarkPieszak / pug-rule-insert.js
Last active October 1, 2017 20:38
Using Pug templates with the Angular-CLI script insert
const fs = require('fs');
const commonCliConfig = 'node_modules/@angular/cli/models/webpack-configs/common.js';
const pug_rule = `\n{ test: /.(pug|jade)$/, loader: "apply-loader!pug-loader?self" },`;
fs.readFile(commonCliConfig, (err, data) => {
if (err) { throw err; }
const configText = data.toString();
// make sure we don't add the rule if it already exists
if (configText.indexOf(pug_rule) > -1) { return; }
@MarkPieszak
MarkPieszak / app.server.module.ts
Last active September 23, 2017 19:11
ngx-swiper mocks for angular universal
// ^ import the SwiperDirective MOCK we made, and include it in your AppServerModule @NgModule
declarations: [
SwiperDirective // <-- this is the mock we made above
],