gulp-banner-footer
Version:
gulp plugin for adding banner or footer to file.
134 lines (103 loc) • 2.44 kB
Markdown
:beer: gulp plugin for adding banner or footer to file.
[](https://www.npmjs.com/package/gulp-banner-footer)
[](https://www.npmjs.com/package/gulp-banner-footer)
```shell
npm install gulp-banner-footer -D
```
```shell
yarn add gulp-banner-footer -D
```
```shell
pnpm add gulp-banner-footer -D
```
```js
const gulp = require('gulp')
const addBannerOrFooter = require('gulp-banner-footer')
// or
// const { addBannerOrFooter } = require(`gulp-banner-footer`)
function styles() {
return gulp
.src('src/styles/**/*.css')
.pipe(
addBannerOrFooter({
banner: file => `
/**
* ${file.basename}
* @author ntnyq
* @license MIT
*/
`,
}),
)
.pipe(gulp.dest('dist'))
}
exports.dev = gulp.series(styles)
```
```ts
import gulp from 'gulp'
import addBannerOrFooter from 'gulp-banner-footer'
// or
// import { addBannerOrFooter } from 'gulp-banner-footer'
const footer = `
/**
* @author ntnyq
* @license MIT
*/
`
function styles() {
return gulp
.src('src/styles/**/*.css')
.pipe(
addBannerOrFooter({
footer,
}),
)
.pipe(gulp.dest('dist'))
}
export const dev = gulp.series(styles)
```
- **type** `string | ((file: Vinyl) => string | undefined)`
- **default** `undefined`
- **required** `false`
static banner content or dynamic banner content based on file information.
- **type** `string | ((file: Vinyl) => string | undefined)`
- **default** `undefined`
- **required** `false`
static footer content or dynamic footer content based on file information.
- **type** `boolean`
- **default** `false`
- **required** `false`
Display filename is being processed.
```ts
interface Vinyl {
contents: Buffer | NodeJS.ReadableStream | null
cwd: string
base: string
path: string
relative: string
dirname: string
basename: string
stem: string
extname: string
isBuffer(): boolean
isStream(): boolean
isNull(): boolean
isDirectory(): boolean
isSymbolic(): boolean
}
```
## Difference from `gulp-banner`
- support add dynamic banner or footer
- support TypeScript
- support esm
- template is removed
## License
[MIT](./LICENSE) License © 2024-PRESENT [ntnyq](https://github.com/ntnyq)