From f7f445c71ee244f32216e6b8a82085fb6499e146 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 6 Aug 2017 18:13:40 +0800 Subject: [PATCH] Add license info to builds (Fix #1126) --- flow-typed/myLibDef.js | 1 + src/index.js | 4 ++++ webpack.config.js | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/flow-typed/myLibDef.js b/flow-typed/myLibDef.js index 7d9a15d..a2094ce 100644 --- a/flow-typed/myLibDef.js +++ b/flow-typed/myLibDef.js @@ -1 +1,2 @@ declare var __DEV__: boolean; +declare var __VERSION__: string; diff --git a/src/index.js b/src/index.js index 423e597..c072e38 100644 --- a/src/index.js +++ b/src/index.js @@ -24,6 +24,10 @@ export type Options = { }; const html2canvas = (element: HTMLElement, config: Options): Promise => { + if (typeof console === 'object' && typeof console.log === 'function') { + console.log(`html2canvas ${__VERSION__}`); + } + const logger = new Logger(); const ownerDocument = element.ownerDocument; diff --git a/webpack.config.js b/webpack.config.js index f4e4b71..1264cf8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,13 @@ const webpack = require('webpack'); +const fs = require('fs'); +const path = require('path'); + +const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'))); + +const banner = +`${pkg.title} ${pkg.version} <${pkg.homepage}> +Copyright (c) ${(new Date()).getFullYear()} ${pkg.author.name} <${pkg.author.url}> +Released under ${pkg.license} License`; module.exports = { entry: './src/index.js', @@ -16,7 +25,9 @@ module.exports = { }, plugins: [ new webpack.DefinePlugin({ - '__DEV__': true - }) + '__DEV__': true, + '__VERSION__': JSON.stringify(pkg.version) + }), + new webpack.BannerPlugin(banner) ] };