0

I have to build a SharePoint Add In app. But, it seems like Microsoft and the SharePoint community has invested heavily in tooling for SharePoint Framework and Add In's are left behind in the past. I would love to leverage the PnP libraries with my add in. I don't know how to set up Gulp to move the files out of the node_modules directory and into the SharePoint Add In folders. The assumption across the board in all online examples and docs is that you are using VS Code or similar and you're building SPFx, not an Add In.

https://pnp.github.io/pnpjs/documentation/getting-started-dev/

I appreciate any advice anyone can offer me so I can leverage what appear to be excellent libraries.

0

I think still you can use SP Pnp js with below Guidelines in your add in

Grab Bundle File

This method is useful if you are primarily working within a script editor web part or similar case where you are not using a build pipeline to bundle your application.

Install only this library.

npm install @pnp/pnpjs

Browse to ./node_modules/@pnp/pnpjs/dist and grab either pnpjs.es5.umd.bundle.js or pnpjs.es5.umd.bundle.min.js depending on your needs. You can then add a script tag referencing this file and you will have a global variable "pnp".

For example you could paste the following into a script editor web part:

<p>Script Editor is on page.</p>
<script src="https://mysite/site assests/pnpjs.es5.umd.bundle.min.js" type="text/javascript"></script>
<script type="text/javascript">

    pnp.Logger.subscribe(new pnp.ConsoleListener());
    pnp.Logger.activeLogLevel = pnp.LogLevel.Info;

    pnp.sp.web.get().then(w => {

        console.log(JSON.stringify(w, null, 4));
    });
</script>

Ref:https://github.com/pnp/pnpjs/blob/dev/packages/pnpjs/docs/index.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.