gulp-wrap
A gulp plugin to wrap a file contents.
Usage
Firstly, install gulp-wrap-file
as a development dependency:
npm install gulp-wrap-file --save-dev
Then, add it into your gulpfile.js
:
Wrap the commonjs contents with amd:
var wrapper = ; gulp ;
Wrap the contents by your file wrapper:
var wrap = ; gulp ;
Wrap the contents with modName:
var wrap = ; gulp ;
example
input
//input.js { console; }
gulpfile.js
var wrap = ; gulp ;
same to the wrapper for function
var wrap = ; gulp ;
output
Parameters
type
Type: String
To wrap file with default support wrapper. On now, it only supports amd
.
wrapper
Type: String
or Function
The file wrapper to wrap your file content. You can get the file content and the pathname of the file.
If wrapper is string, file content names {file}
, short pathname of the file names {modName}
.
If wrapper is function, the arguments of the function are content of the file and the file object.
truncatePrefixLen
Type: Number
To truncate the name of the module prefix. For example, if the module name is path/to/foo. The value of truncatePrefixLen is 1, then the result will be to/foo.
nameReplacer
Type: Function
To handle the module name to what you want. With the config of nameReplacer, truncatePrefixLen will be disabled.