我在 gulp
中有以下任务,我需要在串联文件 (testApp.css) 的开头添加一些版权信息文本。
如何在gulp中实现它?
gulp.task('flat', function () {
gulp.src(['themes/**/*.styl', '!themes/**/**mixins**.styl', '!themes/**/**variables**.styl'])
.pipe(stylus({
compress: true,
use: nib()
}))
.pipe(concat('testAll.css'))
.pipe(gulp.dest('testx'));
});
最佳答案
您可以将前缀与 gulp-insert 一起使用
npm install gulp-insert
与fs
结合使用:
var fs = require('fs');
var insert = require('gulp-insert');
var copyright = function () {
return fs.readFileSync('copyright.txt');
};
gulp.task('flat', function () {
gulp.src(['themes/**/*.styl', '!themes/**/**mixins**.styl', '!themes/**/**variables**.styl'])
// Your other stuff
.pipe(insert.prepend(copyright));
.pipe(gulp.dest('testx'));
});
Check it out on GitHub了解更多信息。
关于javascript - 如何使用 gulp 包含版权信息(来自文本文件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34268799/