目前我遇到以下情况。以下是我的文件夹结构。
-Root
--Products
--Product_1
-- Product_1.html
-- Product_1.js
-- Product_1.css
--Product_2
-- Product_2.html
-- Product_2.js
-- Product_2.css
--Product_3
-- Product_3.html
-- Product_3.js
-- Product_3.css
--Product_4
-- Product_4.html
-- Product_4.js
-- Product_4.css
现在我想创建Products文件夹中可用的所有.js文件的组合包,并使用gulp和/或webpack创建一个bundle.js。
任何人都知道我该怎么做?
答案 0 :(得分:0)
您可以使用gulp-concat来合并所有JS文件。对于您的文件夹结构,您需要以下代码。
var gulp = require ("gulp"),
concat = require ("gulp-concat");
gulp.task ("concatJs", function () {
return gulp.src ("./Products/*/*.js")
.pipe (concat ("bundle.js"))
.pipe (gulp.dest ("./Products/"));
});