Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexmacarthur/vite-plugin-proxy-page

A Vite plugin for projecting your application onto a remote page during development.
https://github.com/alexmacarthur/vite-plugin-proxy-page

local-development proxy spa vite

Last synced: 2 months ago
JSON representation

A Vite plugin for projecting your application onto a remote page during development.

Awesome Lists containing this project

README

        

# vite-plugin-proxy-page

A Vite plugin for developing an application in the context of a remote page.

## What's the Problem?

It's an increasingly common pattern to independently develop small applications outside of the context in which they'll live. For example, an interactive calculator might be built with Vite's out-of-the-box development server, and then be published where it'll be used on the pages of an enterprise CMS -- pages that have their own set of styles, UI quirks, and other characteristics. If you're not careful, you could have unexpected interference with how your application looks or works.

This plugin swaps out your local `index.html` file for a public page of your choosing. You'll get the UI, styles, and other assets just as if you were on the actual page, but still get to keep the snappy developer experience of a typical Vite setup.

## Installation

`npm install vite-plugin-proxy-page`

## Setup

Import the plugin and initialize it your `plugins` array. To avoid issues with the [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react) and similar plugins that deal with JSX, make sure it's the **first** plugin registered in the array.

```js
// vite.config.js

import { proxyPage } from "vite-plugin-proxy-page";

export default defineConfig({
plugins: [
proxyPage({
// Options go here.
}),
],
// ...remaining configuration
});
```

At the very least, you'll need to specify a remote page you'd like to proxy, as well as which local entry point Vite should inject onto the page. By default, this script tag will be injected just before the closing `