我的文件夹结构:
dashboard >
components >
accounts > accounts.js, accountsDirectives.js
dash > dashApp.js
settings > settings.js, settingsDirectives.js
etc...
我在Gulpfile 中的功能
function compile_js(minify, folder) {
var jsLibs = gulp.src('client/'+folder+'/_sources/js/libs/*.js');
var jsPlugins = gulp.src('client/'+folder+'/_sources/js/plugins/*.js');
var jsCustom = gulp.src('client/'+folder+'/_sources/js/custom/*.js');
var jsComponents = gulp.src('client/'+folder+'/components/*.js');
// Order the streams and compile
return streamqueue({ objectMode: true },
jsLibs,
jsPlugins,
jsCustom,
jsComponents
)
.pipe(concat(folder+'.module.js'))
.pipe(gulpif(minify, uglify()))
.pipe(gulp.dest('client/'+folder+'/assets/js'));
};
问题是这一行,它针对组件目录:
var jsComponents = gulp.src('client/'+folder+'/components/*.js');
我也尝试过/components/**/*.js
,但仍然不起作用。
我在这里找到了这个答案,他们谈论符号链接,但我想避免使用它。1) 这看起来像是一次黑客攻击,2)这需要所有当前和未来的开发者在他们的计算机上创建确切的符号链接。
有没有其他方法可以轻松地将所有js文件定位并编译到带有子目录的目录中?
您是否尝试先创建路径,然后使用gull.src参数中的变量?我也很好奇,既然你正在缩小它们,为什么不用之类的东西来抓取其中一些的所有文件呢
var someVar = gulp.src('client/'+folder+'/_sources/js/**/*.js');
与
var jsPlugins = gulp.src('client/'+folder+'/_sources/js/plugins/*.js');
var jsCustom = gulp.src('client/'+folder+'/_sources/js/custom/*.js');