Skip to content

Simple Gulp plugin to prepend a string (e.g. license text).

License

Notifications You must be signed in to change notification settings

bGute/gulp-prepend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-prepend

License:MIT Publish Package npm version

Simple Gulp plugin to prepend a string (e.g. license text) with gulp-sourcemaps support.

Installing

Install the plugin as development dependency:

npm install gulp-prepend --save-dev

Basic Usage

const { src, dest } = require('gulp');
const prepend = require('gulp-prepend');

function prependString() {
	return src('./bundle.js')
		.pipe(prepend('/** \n* @version 0.1.0 \n*/'))
		.pipe(dest('./build'));
}

exports.prependString = prependString;

And with gulp-sourcemaps (example with browserify):

const { src, dest } = require('gulp');
const prepend = require('gulp-prepend');

const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');

function bundle() {
	return browserify({ debug: true, entries: './main.js' })
		.bundle()
		.pipe(source('bundle.js'))
		.pipe(buffer())
		.pipe(sourcemaps.init({ loadMaps: true }))
		.pipe(prepend('/** \n* @version 0.1.0 \n*/'))
		.pipe(sourcemaps.write('.'))
		.pipe(dest('./build'));
}

exports.build = bundle;

Licensing

The code in this project is licensed under MIT license.

About

Simple Gulp plugin to prepend a string (e.g. license text).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published