在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):backflip/gulp-resolve-dependencies开源软件地址(OpenSource Url):https://github.com/backflip/gulp-resolve-dependencies开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-resolve-dependencies
UsageFirst, install npm install --save-dev gulp-resolve-dependencies Then, add it to your var resolveDependencies = require('gulp-resolve-dependencies');
var concat = require('gulp-concat');
gulp.task('js', function(){
gulp.src(['app/assets/js/main.js'])
.pipe(resolveDependencies({
pattern: /\* @requires [\s-]*(.*\.js)/g
}))
.on('error', function(err) {
console.log(err.message);
})
.pipe(concat())
.pipe(gulp.dest('dest/assets/js/'));
}); And use the directives in your JS files (dependencies can be nested, they are handled recursively): /**
* @requires libs/jquery/jquery.js
* @requires ../modules/slideshow/slideshow.js
*/
(function(window, document, $, undefined) {
'use strict';
$(document).on('ready', function() {
$('.slideshow').slideshow();
});
})(window, document, jQuery); Warning: This might not be very efficient (especially in case of nested dependencies). Some kind of caching mechanism could come in handy. Circular dependencies are either silently ignored or emit an error. See
APIresolveDependencies(options)options.patternType: The matching pattern (defaults to options.resolvePathType: Resolver for matched paths. Default: function(match, targetFile) {
return path.join(path.dirname(targetFile.path), match);
} Parameters:
The Returning a falsy value will ignore the resolved path: function(match, targetFile) {
// Ignore `/lib.js`
if (match.match(/\/lib\.js$/)) {
return null;
}
return path.join(path.dirname(targetFile.path), match);
} options.logType: Whether to log the resolved dependencies (defaults to options.ignoreCircularDependenciesType: Whether to just continue instead of emitting an error if circular dependencies are detected (defaults to options.includeType: Only dependencies matching this array of absolute paths will be included (defaults to options.excludeType: Dependencies matching this array of absolute paths will be excluded (defaults to Contributors
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论