build: add banner to build process

This commit is contained in:
Louis Lin 2021-01-22 08:54:13 +01:00
parent 7ca2593d9d
commit 7f3a599f6a
5 changed files with 71 additions and 1190 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

41
package-lock.json generated
View File

@ -539,6 +539,15 @@
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true
},
"concat": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/concat/-/concat-1.0.3.tgz",
"integrity": "sha1-QPM1MInWVGdpXLGIa0Xt1jfYzKg=",
"dev": true,
"requires": {
"commander": "^2.9.0"
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -955,6 +964,19 @@
}
}
},
"handlebars": {
"version": "4.7.6",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz",
"integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==",
"dev": true,
"requires": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
"source-map": "^0.6.1",
"uglify-js": "^3.1.4",
"wordwrap": "^1.0.0"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
@ -1390,6 +1412,12 @@
}
}
},
"neo-async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"node-watch": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.3.5.tgz",
@ -2013,6 +2041,13 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
"uglify-js": {
"version": "3.12.5",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.5.tgz",
"integrity": "sha512-SgpgScL4T7Hj/w/GexjnBHi3Ien9WS1Rpfg5y91WXMj9SY997ZCQU76mH4TpLwwfmMvoOU8wiaRkIf6NaH3mtg==",
"dev": true,
"optional": true
},
"umd": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz",
@ -2203,6 +2238,12 @@
"indexof": "0.0.1"
}
},
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
"dev": true
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -13,7 +13,8 @@
},
"homepage": "https://l-lin.github.io/font-awesome-animation",
"devDependencies": {
"cssmin": "~0.4.3",
"concat": "~1.0.3",
"handlebars": "~4.7.6",
"myth6": "~1.5.0",
"rimraf": "~3.0.2"
},
@ -21,9 +22,12 @@
"node": ">=12.0.0"
},
"scripts": {
"build": "npm run clean && npm run myth && npm run cssmin",
"clean": "rimraf -f dist",
"cssmin": "cssmin dist/font-awesome-animation.css > dist/font-awesome-animation.min.css",
"myth": "mkdir -p dist && myth src/font-awesome-animation.css dist/font-awesome-animation.css --sourcemap"
"build": "npm run clean && npm run init:folders && npm run transform && npm run transform:compress && npm run generate:banner && npm run concat:banner",
"clean": "rimraf -f build dist",
"concat:banner": "concat build/banner.css build/$npm_package_name.css -o dist/$npm_package_name.css && concat build/banner.css build/$npm_package_name.min.css -o dist/$npm_package_name.min.css",
"generate:banner": "node scripts/generate_banner.js build/banner.css",
"init:folders": "mkdir -p build && mkdir -p dist",
"transform": "myth src/font-awesome-animation.css build/$npm_package_name.css --sourcemap",
"transform:compress": "myth src/font-awesome-animation.css build/$npm_package_name.min.css --sourcemap --compress"
}
}

View File

@ -0,0 +1,21 @@
const Handlebars = require('handlebars');
const fs = require('fs');
const pjson = require('../package.json');
const template = Handlebars.compile('/*!\n' +
' * {{ name }} - v{{ version }}\n' +
' * https://github.com/{{ author }}/{{ name }}\n' +
' * License: MIT\n' +
' */');
const result = template(pjson);
const outputFilePath = process.argv.slice(1)[1];
fs.writeFile(outputFilePath, result, err => {
if (err) {
console.log(err);
process.exit(1);
}
});