vite-plugin-auto-origin
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Vite Auto Origin

This plugin for vite aims to set the server.origin configuration option automatically to the external URL of the vite dev server. This leads to the vite dev server serving additional assets (e. g. referenced images or font files) during development instead of the main application server.

This is useful in situations where the url structure of the application server differs from the original directory structure or if certain files aren't publicly accessible.

In thise case, you would need to specify server.origin manually in your vite.config.js, which this plugin does automatically.

Installation

npm install --save-dev vite-plugin-auto-origin

Usage

vite.config.js:

import autoOrigin from "vite-plugin-auto-origin";

export default defineConfig({
    plugins: [autoOrigin()],
    // ...
});

Use case: TYPO3

This plugin was created to allow easier integration of vite with TYPO3 CMS. In TYPO3 setups, the original asset sources are usually located in Resources/Private/, which isn't served by the web server, and only assets generated by vite build will be created in public/_assets/vite/ and thus will be publicly available. This is why the vite dev server needs to serve the asset files in development context.

vite_asset_collector implements the server-side integration of vite and TYPO3.

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-auto-origin

Weekly Downloads

397

Version

1.0.2

License

MIT

Unpacked Size

7.75 kB

Total Files

7

Last publish

Collaborators

  • s2bproject