vite-plugin-create-file

0.2.0 • Public • Published

vite-plugin-create-file

adds one or multiple files to your build (outDir) directory.

usage

only one file written

import { defineConfig } from 'vite';
import Writer from 'vite-plugin-create-file';

export default defineConfig({
  // ...
  plugins: [
    Writer({
      // outDir: './dist',
      // content: 'test',
      filename: 'name.txt', // required
    }),
  ],
});

write multiple files

use an array with objects ...

import { defineConfig } from 'vite';
import Writer from 'vite-plugin-create-file';

export default defineConfig({
  // ...
  plugins: [
    Writer([
      {
        outDir: './dist',
        // content as a callback function
        // which should return a string
        content: (config) => {
          // you can use config here (if needed)
          return 'my string 1';
        },
        filename: 'test1.txt',
      },
      {
        outDir: './dist',
        content: 'my string 2',
        filename: 'test2.txt',
      },
    ]),
  ],
});

options

{
  // The storage directory.
  // required: false
  // Type: String
  outDir: './dist',

  // The content of the file.
  // required: false
  // Type: String, function (which returns a string)
  content: 'test',

  // The name of the file.
  // required: true
  // Type: String
  filename: 'name.txt', // required
}

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-create-file

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

5.55 kB

Total Files

4

Last publish

Collaborators

  • lemon3