1.2.0 • Published 4 months ago

gulp-banner-footer v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

gulp-banner-footer

:beer: gulp plugin for adding banner or footer to file.

NPM VERSION NPM DOWNLOADS

Install

npm install gulp-banner-footer -D
yarn add gulp-banner-footer -D
pnpm add gulp-banner-footer -D

Usage

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)
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)

Options

banner

  • type string | ((file: Vinyl) => string | undefined)
  • default undefined
  • required false

static banner content or dynamic banner content based on file information.

footer

  • type string | ((file: Vinyl) => string | undefined)
  • default undefined
  • required false

static footer content or dynamic footer content based on file information.

verbose

  • type boolean
  • default false
  • required false

Display filename is being processed.

Interface

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 © 2024-PRESENT ntnyq