javascript - 如何使用 gulp 包含版权信息(来自文本文件)?

标签 javascript gulp

我在 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/

相关文章:

javascript - jQuery : Split the DOM Node using jQuery

Javascript代码进入无限循环

javascript - gulpfile.js 在 sass 构建后没有连接所有 css

css - Gulp CSS 任务不会覆盖现有的 CSS

javascript - CSS 缩放以适应内容,无需滚动

javascript - 是否可以在 JS 中重新创建 "new"运算符?

android - 基于 generator-gulp-angular 在 Ionic 项目上配置 Live Reload

javascript - 如何捆绑除指定需求之外的 commonjs 模块

docker - “docker-compose up”之后如何运行gulp?

javascript - 在两个组件之间传输状态