vite-plugin-shebang
v0.1.6
Published
Vite plugin to prepend a shebang to output flies.
Downloads
7
Maintainers
Readme
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 inpackage.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)],
});