【发布时间】:2015-11-08 15:06:13
【问题描述】:
如何使用gulp来组织不同html中不同的js文件?
我能做的唯一方法是将每个页面定义为 gulp 任务吗?还是 gulp 有更好的方法可以自动检测文件?
这是我下面的情况。
我有两个 html 'index.html','content.html'
-
index.html需要plugin_A.js -
content.html需要plugin_B.js
还有我的 gulp 文件:
gulp.task('index_concat', function() {
return gulp.src('./app/js/plugin_A.js')
.pipe(concat('index.js'))
.pipe(gulp.dest('./build/js/'));
});
gulp.task('content_concat', function() {
return gulp.src('./app/js/plugin_B.js')
.pipe(concat('content.js'))
.pipe(gulp.dest('./build/js/'));
});
如果我有 100 页,任务就太大了!!! 我认为这是定义每个页面的愚蠢方式,但我不知道如何变得更好。请给我一些建议。
【问题讨论】: