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.
- Host: GitHub
- URL: https://github.com/fastify/vite-plugin-blueprint
- Owner: fastify
- Created: 2021-10-23T11:11:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-23T09:13:30.000Z (almost 2 years ago)
- Last Synced: 2024-05-13T05:09:31.452Z (almost 2 years ago)
- Topics: fastify-frontend
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 17
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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