Use a supported workaround to get the script root.
This commit is contained in:
parent
ec192e1c62
commit
b3a87a7672
Binary file not shown.
After Width: | Height: | Size: 156 B |
|
@ -36,11 +36,7 @@ export default class ScriptEditorWebPart extends BaseClientSideWebPart<IScriptEd
|
|||
this.executeScript(this.domElement);
|
||||
} else {
|
||||
// Dynamically load the editor pane to reduce overall bundle size
|
||||
let scriptRoot = (<any>this.context.manifest).loaderConfig.internalModuleBaseUrls[0];
|
||||
if (scriptRoot.indexOf("localhost") != -1) {
|
||||
scriptRoot += "dist/";
|
||||
}
|
||||
const editorPopUp: any = await SPComponentLoader.loadScript(scriptRoot + '/editor-pop-up.min.js', { globalExportsName: "EditorPopUp" });
|
||||
const editorPopUp: any = await SPComponentLoader.loadScript(this.getScriptRoot() + '/editor-pop-up.min.js', { globalExportsName: "EditorPopUp" });
|
||||
const element: React.ReactElement<IScriptEditorProps> = React.createElement(
|
||||
editorPopUp.default,
|
||||
{
|
||||
|
@ -53,6 +49,15 @@ export default class ScriptEditorWebPart extends BaseClientSideWebPart<IScriptEd
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a dummy bundled image to get the path from where the bundle is served.
|
||||
*/
|
||||
private getScriptRoot(): string {
|
||||
const runtimePath: string = require('./1x1.png');
|
||||
const scriptRoot = runtimePath.substr(0, runtimePath.lastIndexOf("/"));
|
||||
return scriptRoot;
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue