在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mariusschulz/gulp-iife开源软件地址(OpenSource Url):https://github.com/mariusschulz/gulp-iife开源编程语言(OpenSource Language):JavaScript 60.7%开源软件介绍(OpenSource Introduction):gulp-iifeA Gulp plugin for wrapping JavaScript code within immediately invoked function expressions (IIFEs). Install
Usagevar gulp = require("gulp");
var iife = require("gulp-iife");
gulp.task("default", function() {
return gulp.src("src/input.js")
.pipe(iife())
.pipe(gulp.dest("dist"));
}); Input file: var greeting = "Hello, World!";
console.log(greeting); Output file: ;(function() {
"use strict";
var greeting = "Hello, World!";
console.log(greeting);
}()); OptionsYou can configure the following options: Here's an example specifying all available options: var gulp = require("gulp");
var iife = require("gulp-iife");
gulp.task("default", function() {
return gulp.src("src/input.js")
.pipe(iife({
useStrict: true,
trimCode: true,
prependSemicolon: false,
bindThis: false,
params: ["window", "document", "$", "undefined"],
args: ["window", "document", "jQuery"]
}))
.pipe(gulp.dest("dist"));
}); Input file: var greeting = "Hello, World!";
console.log(greeting); Output file: (function(window, document, $, undefined) {
"use strict";
var greeting = "Hello, World!";
console.log(greeting);
}(window, document, jQuery));
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论