1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-28 18:45:48 +00:00

Improve the copyrights of the assets

This commit is contained in:
Cotes Chung
2021-01-25 06:20:51 +08:00
parent cbb3bd4be5
commit 893db51ff0
72 changed files with 139 additions and 342 deletions

View File

@@ -7,9 +7,12 @@ const { src, dest, watch, series, parallel} = require('gulp');
const concat = require('gulp-concat');
const rename = require("gulp-rename");
const uglify = require('gulp-uglify');
const insert = require('gulp-insert');
const fs = require('fs');
const JS_ROOT = './assets/js';
const jsDest = `${ JS_ROOT }/dist/`;
const copyrightPath = `${ JS_ROOT }/.copyright`;
function concatJs(files, output) {
return src(files)
@@ -20,7 +23,8 @@ function concatJs(files, output) {
function minifyJs() {
return src(`${ jsDest }/*.js`)
.pipe(uglify())
.pipe(insert.prepend(fs.readFileSync(copyrightPath, 'utf8')))
.pipe(uglify({output: {comments: /^!|@preserve|@license|@cc_on/i}}))
.pipe(dest(jsDest));
}
@@ -63,10 +67,7 @@ const pageJs = () => {
// GA pageviews report
const pvreportJs = () => {
return concatJs([
`${JS_ROOT}/_utils/pageviews.js`
], 'pvreport'
);
return concatJs(`${JS_ROOT}/_utils/pageviews.js`, 'pvreport');
};
const buildJs = parallel(homeJs, postJs, categoriesJs, pageJs, pvreportJs);
@@ -78,7 +79,8 @@ exports.liveRebuild = () => {
watch([
`${ JS_ROOT }/_commons/*.js`,
`${ JS_ROOT }/_utils/*.js`
`${ JS_ROOT }/_utils/*.js`,
`${ JS_ROOT }/lib/*.js`
],
buildJs
)