Using gulp-header and Node’s file system npm install --save-dev gulp-header
Copyright 头文件
# vim Copyright /* Author: netkiller <netkiller@msn.com> Website: https://www.netkiller.cn Version: <%= version %> */
Version 文件
# vim Version 1.0.0
gulpfile.js:
// including plugins var gulp = require('gulp') , fs = require('fs') , concat = require("gulp-concat") , header = require("gulp-header"); // functions // Get version using NodeJs file system var getVersion = function () { return fs.readFileSync('Version'); }; // Get copyright using NodeJs file system var getCopyright = function () { return fs.readFileSync('Copyright'); }; // task gulp.task('concat-copyright-version', function () { gulp.src('./javascript/*.js') .pipe(concat('finaly.js')) // concat and name it "concat-copyright-version.js" .pipe(header(getCopyrightVersion(), {version: getVersion()})) .pipe(gulp.dest('path/to/destination')); });
Run:
gulp concat-copyright-version
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。