我在尋找將我的gulpfile.js assets
或src
變量拆分爲單獨的文件,以便我可以更好地管理它們。例如:從單獨的gulp文件導入/讀取變量
....
var scripts = ['awful.js', 'lot.js', 'of.js', 'js.js', 'files.js']
....(somewhere down the line)
gulp.task('vendorjs', function() {
return gulp.src(scripts)
.pipe(concat('vendor.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(paths.root + 'dist'))
.pipe(notify({ message: 'vendorjs task completed' }));
});
那麼,我基本上是有興趣,如果那裏有一種方式實際移動到一個單獨的文件中scripts
變量,能夠從gulpfile.js
訪問它。
我一直在尋找到類似:
require("fs").readFile('gulp/test.js', function(e, data) {
//(test.js would be the file that holds the scripts var)
});
Howerver而它讀取該文件的內容,我仍然無法從gulpfile.js
訪問它。任何提示或想法都非常感謝。
聽起來是正確的,測試了它並且工作得很好。謝謝! (20小時內將發送賞金:)) – RGLSV