@hankei6km/rollup-plugin-nodebox-fs-files
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

rollup-plugin-nodebox-fs-files

Converts file to Nodebox files.

Installation

npm install --save-dev @hankei6km/rollup-plugin-nodebox-fs-files

Usage

// 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

// 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.

// src/files.mjs
export const files = {}

Examples

misc directory is ignored.

// 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.

// 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.

// vite.config.js
import { defineConfig } from 'vite'
import { nodeboxFsFiles } from '@hankei6km/rollup-plugin-nodebox-fs-files'

export default defineConfig({
  plugins: [
    nodeboxFsFiles({
      from: 'box-src/vite-project',
      insertTo: 'src/files.mjs'
    })
  ]
})

License

MIT License

Copyright (c) 2023 hankei6km

Package Sidebar

Install

npm i @hankei6km/rollup-plugin-nodebox-fs-files

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

9.14 kB

Total Files

9

Last publish

Collaborators

  • hankei6km