Rollup / Vite plugin that wires sp-rest-proxy into the dev server so SharePoint REST calls resolve locally while you build.
- Built and tested against Vite 7.x (Rollup 4.x, Node 18+).
- Use
rollup-plugin-sp-rest-proxy@^2for Vite 5–7 projects. - If you are pinned to Vite 4 or earlier, install
rollup-plugin-sp-rest-proxy@^1, which keeps the old default export.
npm install -D rollup-plugin-sp-rest-proxy
# or
pnpm add -D rollup-plugin-sp-rest-proxyimport { defineConfig } from "vite";
import { RollupPluginSPRestProxy } from "rollup-plugin-sp-rest-proxy";
const rollupPluginSPRestProxy = new RollupPluginSPRestProxy();
export default defineConfig({
server: {
proxy: {
...rollupPluginSPRestProxy.viteProxySetting(),
},
},
plugins: [rollupPluginSPRestProxy.rollupPlugin()],
});import { defineConfig } from "vite";
import { RollupPluginSPRestProxy } from "rollup-plugin-sp-rest-proxy";
export default defineConfig(
RollupPluginSPRestProxy.mergeViteConfig({
/* your vite config */
})
);- The constructor accepts the underlying
sp-rest-proxysettings; defaults are{ port: 9090, hostname: "localhost" }. viteProxySettingmerges the SharePoint_apiproxy into any existing Vite proxy map while preserving your other entries.
- v2 switches to named exports only; update imports accordingly.
- Dependencies are bumped to
sp-rest-proxy@^3.3.6,portfinder@^1.0.28, and Vite 7.x to stay current with upstream fixes.