Last active
June 9, 2017 06:34
-
-
Save waldekmastykarz/822904bf47039af9a01bdda422a84477 to your computer and use it in GitHub Desktop.
SPFx gulpfile.js with additional task to show query string parameters for debugging extensions
This file contains hidden or 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
'use strict'; | |
const gulp = require('gulp'); | |
const build = require('@microsoft/sp-build-web'); | |
build.task('serve-info', { | |
execute: (config) => { | |
return new Promise((resolve, reject) => { | |
var serveTask = config.uniqueTasks.find((task) => { | |
return task.name === 'serve'; | |
}); | |
var url = `http${serveTask.taskConfig.https ? 's' : ''}://${serveTask.taskConfig.hostname}:${serveTask.taskConfig.port}/temp/manifest.js`; | |
for (var key in config.properties.manifests) { | |
var manifest = config.properties.manifests[key]; | |
if (manifest.componentType !== 'Extension') { | |
continue; | |
} | |
console.log(`${manifest.alias}:`); | |
switch (manifest.extensionType) { | |
case "ApplicationCustomizer": | |
console.log(`?loadSPFX=true&debugManifestsFile=${url}&customActions={"${manifest.id}":{"location":"ClientSideExtension.ApplicationCustomizer","properties":{"prop1":"val1"}}}`); | |
break; | |
case "FieldCustomizer": | |
console.log(`?loadSPFX=true&debugManifestsFile=${url}&fieldCustomizers={"FieldName":{"id":"${manifest.id}","properties":{"prop1":"val1"}}}`); | |
break; | |
case "ListViewCommandSet": | |
console.log(`?loadSpfx=true&debugManifestsFile=${url}&customActions={"${manifest.id}":{"location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}`); | |
break; | |
} | |
console.log(); | |
} | |
resolve(); | |
}); | |
} | |
}); | |
build.initialize(gulp); | |
gulp.tasks['serve-info'].dep.push('serve'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment