Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samvv/shebang2-loader
An alternative Webpack loader for Unix-style shebangs (usually #!/usr/bin/env node)
https://github.com/samvv/shebang2-loader
Last synced: about 1 month ago
JSON representation
An alternative Webpack loader for Unix-style shebangs (usually #!/usr/bin/env node)
- Host: GitHub
- URL: https://github.com/samvv/shebang2-loader
- Owner: samvv
- License: mit
- Created: 2020-06-05T08:00:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T16:48:05.000Z (almost 2 years ago)
- Last Synced: 2024-11-16T01:12:20.018Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://npmjs.com/package/shebang2-loader
- Size: 486 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# shebang2-loader
This is an alternative Webpack loader for Unix-style shebangs (usually `#!/usr/bin/env node`). It is meant to replace the
[shebang-loader](https://npmjs.com/package/shebang-loader), which appears to be unmaintained and does not have proper
support for source maps.## Usage
1. Make this package available to Webpack:
```
npm i -D shebang2-loader
```
or
```
yarn add -D shebang2-loader
```2. Configure the loader in your `webpack.config.js`.
```js
module: {
rules: [
// ...
{ test: /example\/index.js$/, loader: "shebang2-loader" },
]
}
```
**Make sure to place `shebang2-loader` as the last rule in the list of rules, so that Webpack will process it first.**
Here's a full example using Webpack's [BannerPlugin](https://webpack.js.org/plugins/banner-plugin/) to re-generate the
shebang for a CLI application.```js
const webpack = require("webpack");
const path = require("path");module.exports = {
target: 'node',
mode: 'development',
entry: './main.js',
output: {
filename: 'dist.js',
path: path.resolve(__dirname),
},
plugins: [
new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),
],
devtool: 'source-map',
module: {
rules: [
{ test: /\.m?js$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /example\/index.js$/, loader: "shebang2-loader" },
]
}
};
```
3. Run Webpack as you'd usually do.```
webpack --watch --config webpack.config.js
```
## LicenseThis software is licensed under the MIT license.