From f9b4253d45f1fafd41973249d56536b17fbe29ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Fus?= Date: Mon, 9 Dec 2024 16:34:21 +0100 Subject: [PATCH] Added license header to dist files. (#60) * Added licese header to dist files. * Licenses: Added info to build package. * Fixed warning --- package-build.json | 2 +- tsconfig.json | 1 + webpack.config.ts | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/package-build.json b/package-build.json index 03cb920..9ebbdb8 100644 --- a/package-build.json +++ b/package-build.json @@ -2,7 +2,7 @@ "private": true, "version": "1.0.0", "name": "@highcharts/connectors-morningstar", - "license": "UNLICENSED", + "license": "https://shop.highcharts.com/contact/partner-data", "description": "Highcharts connectors for Morningstar Direct Web Services", "author": "Highsoft AS", "bugs": "https://www.highcharts.com/support/", diff --git a/tsconfig.json b/tsconfig.json index d47ec5e..ab6040f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -117,6 +117,7 @@ // same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable "compilerOptions": { "allowJs": true, + "resolveJsonModule": true, "module": "CommonJS" } } diff --git a/webpack.config.ts b/webpack.config.ts index 1e76d66..bc123f4 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -9,6 +9,9 @@ import type { Configuration } from 'webpack'; import * as FS from 'node:fs'; import * as Path from 'node:path'; +import * as Webpack from 'webpack'; +import * as TerserPlugin from 'terser-webpack-plugin'; +import { version } from './package-build.json'; /* * * @@ -44,6 +47,15 @@ const sourceFolder = './code/es-modules/'; const targetFolder = './code/'; + +const banner = `/** +* Highcharts Connectors for Morningstar Direct Web Services ` + +`v${version} (${new Date().toISOString().split('T')[0]}) +* (c) 2009-2024 Highsoft AS +* License: https://shop.highcharts.com/contact/partner-data +**/`; +const license = /License: https:\/\/shop.highcharts.com\/contact\/partner-data/u; + /* * * * Distribution @@ -130,7 +142,6 @@ const sharedConfiguration: Configuration = { }; - const webpacks: Array = Object.keys(metas).map(variant => ({ ...sharedConfiguration, @@ -192,6 +203,31 @@ for (let webpack of webpacks.slice()) { } +// Enable header for all production builds. This is used to add the license +// header to the minified files too. +webpacks.forEach(webpack => { + webpack.plugins = [ + new Webpack.BannerPlugin({ + banner: banner, + raw: true + }) + ]; + + if (!webpack.optimization) { + webpack.optimization = {}; + } + + webpack.optimization.minimizer = [ + new TerserPlugin({ + terserOptions: { + format: { + comments: license // Keep comments that include "License:" + } + }, + extractComments: false + }) + ]; +}); /* * *