Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hankei6km/rollup-plugin-nodebox-fs-files
Converts files to Nodebox files
https://github.com/hankei6km/rollup-plugin-nodebox-fs-files
nodebox rollup-plugin vite-plugin
Last synced: 2 months ago
JSON representation
Converts files to Nodebox files
- Host: GitHub
- URL: https://github.com/hankei6km/rollup-plugin-nodebox-fs-files
- Owner: hankei6km
- License: mit
- Created: 2023-05-16T08:39:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T08:24:10.000Z (3 months ago)
- Last Synced: 2024-10-29T09:25:01.596Z (3 months ago)
- Topics: nodebox, rollup-plugin, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 914 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup-plugin-nodebox-fs-files
Converts file to [Nodebox](https://sandpack.codesandbox.io/docs/advanced-usage/nodebox) [files](https://github.com/codesandbox/nodebox-runtime/blob/main/packages/nodebox/api.md#nodeboxfsinitfiles).
## Installation
```shell
npm install --save-dev @hankei6km/rollup-plugin-nodebox-fs-files
```## Usage
```js
// rollup.config.js
import nodeboxFsFiles from '@hankei6km/rollup-plugin-nodebox-fs-files'export default {
input: 'src/index.mjs',
plugins: [
nodeboxFsFiles({
from: 'box-src/proj',
insertTo: 'src/files.mjs'
})
]
}
```from
```
box-src/proj/
├── index.js
├── node_modules
│ └── ...
├── public
│ └── image.png
└── src
└── lib.js
```to
```js
// src/files.mjs
export const files = {
'index.js': 'console.log(...;\n',
'public/image.png': { type: 'Buffer', data: [97, 98, 99 /*...*/] },
'src/lib.js': 'export default ...;\n'
}
```> NOTE: Define a temporary `export` to bypass a linting error.
>
> ```js
> // src/files.mjs
> export const files = {}
> ```## Examples
`misc` directory is ignored.
```js
// rollup.config.js
import nodeboxFsFiles from '@hankei6km/rollup-plugin-nodebox-fs-files'export default {
input: 'src/index.mjs',
plugins: [
nodeboxFsFiles({
from: 'box-src/proj',
insertTo: 'src/files.mjs',
excludeFrom: '**/misc/**'
})
]
}
```converts `.mp4` and `.mp3` files as binary.
```js
// rollup.config.js
import nodeboxFsFiles from '@hankei6km/rollup-plugin-nodebox-fs-files'export default {
input: 'src/index.mjs',
plugins: [
nodeboxFsFiles({
from: 'box-src/proj',
insertTo: 'src/files.mjs',
binaryFile: ['**/*.mp4', '**/*.mp3']
})
]
}
```vite example.
```js
// vite.config.js
import { defineConfig } from 'vite'
import { nodeboxFsFiles } from '@hankei6km/rollup-plugin-nodebox-fs-files'export default defineConfig({
plugins: [
nodeboxFsFiles({
from: 'box-src/proj',
insertTo: 'src/files.mjs'
})
]
})
```## License
MIT License
Copyright (c) 2023 hankei6km