Skip to content

Instantly share code, notes, and snippets.

View estruyf's full-sized avatar
:octocat:
Front Matter CMS

Elio Struyf estruyf

:octocat:
Front Matter CMS
View GitHub Profile
@estruyf
estruyf / hubsite-data.json
Created August 14, 2019 16:44
Hubsite data
{
"HubSiteId": "d63d74d9-dfb7-46ce-8f04-c1d6d674075c",
"IsHubSite": true
}
@estruyf
estruyf / app-customizer-navigation-checks.ts
Created June 19, 2019 08:26
Application Customizer navigation checks
interface NavigationEventDetails extends Window {
isNavigatedEventSubscribed: boolean;
currentPage: string;
currentHubSiteId: string;
currentUICultureName: string;
}
declare const window: NavigationEventDetails;
export default class NavigationApplicationCustomizer extends BaseApplicationCustomizer<INavigationApplicationCustomizerProperties> {
@estruyf
estruyf / spfx-debugging-bookmarklet.js
Created June 3, 2019 14:17
SPFx Debugging Bookmarklet
javascript:(() => {
const url = new URL(window.location.href);
url.searchParams.set("loadSPFX", true);
url.searchParams.set("debugManifestsFile", "https://localhost:4321/temp/manifests.js");
document.location = url.href;
})();
@estruyf
estruyf / rush-stack-compiler-3.3
Created March 16, 2019 08:38
rush-stack-compiler-3.3
// BEFORE
"extends": "./node_modules/@microsoft/rush-stack-compiler-2.7/includes/tsconfig-web.json"
// AFTER
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json"
@estruyf
estruyf / lazy-loaded-component.tsx
Created March 14, 2019 21:05
React lazy loading components
import * as React from 'react';
import styles from './HelloWorld.module.scss';
import { IHelloWorldProps } from './IHelloWorldProps';
export default class HelloWorld extends React.Component<IHelloWorldProps, {}> {
private OtherComponent = React.lazy(() => import('./TestComponent' /* webpackChunkName: "testcomponent" */));
public render(): React.ReactElement<IHelloWorldProps> {
return (
<div className={ styles.helloWorld }>
@estruyf
estruyf / tsconfig.compiler.json
Created March 14, 2019 21:04
Update compiler version in the tsconfig file
// BEFORE
"extends": "./node_modules/@microsoft/rush-stack-compiler-2.7/includes/tsconfig-web.json"
// AFTER
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.2/includes/tsconfig-web.json"
@estruyf
estruyf / partially-reload-on-navigation.ts
Created February 28, 2019 20:39
Partially reload the page on navigation
const link = "<your-url>";
const navState = { url: link };
// Adds the new navigation state to the browser history
history.pushState(navState, null, link);
const newPopState = new PopStateEvent("popstate", { state: navState });
window.dispatchEvent(newPopState);
@estruyf
estruyf / buildrig.warnings.js
Created February 20, 2019 08:27
Set the warning level to fail the build
// Note this overrides the getters for ship and production on args
this.args.ship = this.args.production = (this.args.production || this.args.ship);
// Since gulp-core-build doesn't recognize the --ship flag, ensure it gets the right state
coreBuild.mergeConfig({
production: this.args.ship,
shouldWarningsFailBuild: this.args.ship
});
@estruyf
estruyf / gulpfile.warnings.js
Created February 20, 2019 08:12
SPFx gulpfile with the ability to let warnings not fail the build
// @ts-check
'use strict';
const gulp = require('gulp');
const build = require("@microsoft/sp-build-web");
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
// Retrieve the current build config and check if there is a `warnoff` flag set
const crntConfig = build.getConfig();
const warningLevel = crntConfig.args["warnoff"];
@estruyf
estruyf / gulp.logging.example2.js
Created February 12, 2019 08:33
SharePoint Framework gulp logging the right way
const testingTask = build.subTask("testing", async function (gulp, buildOptions, done) {
this.log('LOG: Just logging');
this.logWarning('WARNING: Just a warning!');
this.logError(`ERROR: ohh, no, this doesn't look good!`);
});
build.task("testing", testingTask);