vite-plugin-shebang
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

vite-plugin-shebang

A Vite plugin to prepend a custom shebang to JavaScript files based on the module type specified in package.json.

Features

  • Prepends a custom shebang to JavaScript files
  • Automatically detects bin files based on the bin field in package.json

Installation

Install the plugin via npm:

npm install vite-plugin-shebang --save-dev

Usage

Specify your options:

const options: PrependShebangOptions = {
    // The shebang string to prepend to the file.
    shebang: "#!/usr/bin/env node",
    // The output file names to prepend the shebang to.
    files: ["index.cjs"],
};

And then call the plugin in your build chain:

// vite.config.ts
import { defineConfig } from "vite";
import { prependShebang } from "vite-plugin-shebang";

export default defineConfig({
    plugins: [prependShebang(options)],
});

Package Sidebar

Install

npm i vite-plugin-shebang

Weekly Downloads

8

Version

0.1.6

License

MIT

Unpacked Size

10.3 kB

Total Files

8

Last publish

Collaborators

  • mkbabb