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

https://github.com/fastify/vite-plugin-blueprint

Vite plugin for shadowing files from a blueprint folder.
https://github.com/fastify/vite-plugin-blueprint

fastify-frontend

Last synced: 5 months ago
JSON representation

Vite plugin for shadowing files from a blueprint folder.

Awesome Lists containing this project

README

          

# vite-plugin-blueprint

A [Vite](https://vitejs.dev/) plugin that lets you easily shadow files in your app directory from a _blueprint_.

Take this simple Vite app as example:

```
example/
├── blueprint/
│ ├── foobar.js
│ └── main.js
├── index.html
└── vite.config.js
```

And this **vite.config.js**:

```js
import vitePluginBlueprint from 'vite-plugin-blueprint'

export default {
plugins: [
vitePluginBlueprint({
root: resolve => resolve(import.meta.url, 'blueprint'),
prefix: '@blueprint/',
files: [
// Searches foobar.js in the app root directory,
// if not found, provide foobar.js from the blueprint root
['foobar.js'],
// Searches for either main.js, index.js or start.js in the app root directory,
// if not found, provide main.js from the blueprint root
['main.js', ['index.js', 'start.js']],
],
}),
],
}
```

Now, if you delete the `main.js` file at the root, the app will still compile because that file will be shadowed by `main.js` under `blueprint/`, as long as you use the prefix you set when referencing files:

```html




Vite App backed by Blueprint




```

## Install

```bash
npm i vite-plugin-blueprint --save-dev
```

## License

MIT