support license for compress css
This commit is contained in:
@@ -2,21 +2,35 @@ var gulp = require ('gulp'),
|
||||
minifycss = require('gulp-minify-css'),
|
||||
rename = require('gulp-rename'),
|
||||
uglify = require ('gulp-uglify'),
|
||||
clean = require('gulp-clean');
|
||||
clean = require('gulp-clean'),
|
||||
license = require('gulp-header-license'),
|
||||
fs = require('fs');
|
||||
|
||||
gulp.task ('clean', function () {
|
||||
gulp.src('../*/css/*.min.css').pipe(clean({force: true}));
|
||||
gulp.task ('clean', function (cb) {
|
||||
var stream = gulp.src('../*/css/*.min.css').pipe(clean({force: true}));
|
||||
gulp.src('../*/js/*.min.js').pipe(clean({force: true}));
|
||||
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task ('build', function () {
|
||||
gulp.src ('../*/css/*.css')
|
||||
gulp.task ('build', ['clean'], function (cb) {
|
||||
var stream = gulp.src ('../*/css/*.css')
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(minifycss({keepSpecialComments: '1'}))
|
||||
.pipe(minifycss())
|
||||
.pipe(gulp.dest ('../'));
|
||||
|
||||
gulp.src ('../*/js/*.js')
|
||||
.pipe(rename({ suffix: '.min' }))
|
||||
.pipe(uglify({preserveComments: 'license'}))
|
||||
.pipe(gulp.dest ('../'));
|
||||
});
|
||||
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task ('license', ['clean', 'build'], function () {
|
||||
gulp.src('../*/css/*.min.css')
|
||||
.pipe(license(fs.readFileSync('header.txt', 'utf8'), {year: (new Date()).getFullYear()}, 1))
|
||||
.pipe(gulp.dest('../'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean', 'build', 'license']);
|
15
toolers/header.txt
Normal file
15
toolers/header.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2010-${year}, b3log.org & hacpai.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
@@ -6,6 +6,7 @@
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-clean": "^0.3.2",
|
||||
"gulp-header-license": "^1.0.6",
|
||||
"gulp-minify-css": "^1.2.4",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-uglify": "^2.0.0"
|
||||
|
Reference in New Issue
Block a user