Socket
Book a DemoInstallSign in
Socket

vite-plugin-create-file

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-create-file

create additional files

0.2.0
latest
npmnpm
Version published
Maintainers
1
Created
Source

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
}

FAQs

Package last updated on 17 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.