npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

spfx-build-url-rewrite

v1.0.3

Published

SharePoint Framework URL rewrite build tool

Downloads

113

Readme

spfx-build-url-rewrite

SharePoint Framework build tool that automatically re-writes URL's in the manifest.

npmjs

Why?

For ISV's and SI's the SharePoint Framework has a huge disadvantage in how configuration is handled. It contains hardcoded references to external URL's and hosting location of the bundled SharePoint Framework files. If you are re-using a SharePoint Framework solution for multiple tenants/clients/environments you need to manually modify the configuration files between each build. The spfx-build-url-rewrite allows you to rewrite these URL's at build time to build packages targeted to specific tenants/URLs without modifying the SharePoint Framework configuration files.

Installation

You add the package to your SPFx solution as follows:

npm install spfx-build-url-rewrite --save

In order to use the package you need to modify the gulpfile.js file as follows. Before the line containing build.initialize(gulp); insert the following lines:

const rewrite = require('spfx-build-url-rewrite');
rewrite.config(build);

Usage

To be able to rewrite external URLs (stored in ./config/config.json) and the CDN URL (stored in ./config/write-manifest.json) you must adress the URLs using the following URL https://contoso.sharepoint.com.

Example of config.json:

 "externals": {
    "sp-init": {
      "path": "https://contoso.sharepoint.com/_layouts/15/init.js",
      "globalName": "$_global_init"
    },
    "microsoft-ajax": {
      "path": "https://contoso.sharepoint.com/_layouts/15/MicrosoftAjax.js",
      "globalName": "Sys",
      "globalDependencies": [
        "sp-init"
      ]
    }
 }

Example of write-manifest.json:

{
  "cdnBasePath": "https://contoso.sharepoint.com/CDN_Library"
}

How to rewrite during the build

You have two options to do the re-write during your build; either using the command line or using environment variables

Rewrite using the command line

In order to re-write using the command line use the --target-cdn argument like this:

gulp build --target-cdn https://fabrikam.sharepoint.com

Rewrite using environment variables

To avoid specifying the command line argument you can use the TargetCdn (process.enc.TargetCdn) environment variable. To use argument variables in the command line you can create a file called .env in the root folder and add content as follows:

TargetCdn=https://fabrikam.sharepoint.com