gulp-wrap-exports

2019-05-17 admin

gulp-wrap-exports是什么

什么是gulp-wrap-exports,Wrap CommonJS module in IIFE and create global variable

gulp-wrap-exports使用教程帮助文档

gulp-wrap-exports

Wrap CommonJS module in IIFE and create global variable

Install

npm install --save-dev gulp-wrap-exports

Example

var gulp = require('gulp'),
	wrap = require('gulp-wrap-exports');

gulp.task('default', function(){
	return gulp.src('fn-module.js')
		.pipe(wrap({ name: 'fn' }))
		.pipe(gulp.dest('dest/'));
});

Example input:

exports.processing = function(){};

Example output (name: 'module'):

!function(exports, global){
	global.module = exports;

	exports.processing = function(){};

}({}, function(){ return this; }());

Options

String name - valid name of global variable which should be available in browser.

License

MIT License © Alexey Raspopov

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65149.html

文章标题:gulp-wrap-exports

回到顶部