From 291cb6481f29774ea1b03c3478d42f892d7379e5 Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Thu, 25 Apr 2024 14:32:41 +0200 Subject: [PATCH] Minified version of the lib --- webpack.config.js | 92 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 2531e843..ac88b0ca 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,26 +1,74 @@ const path = require('path'); +const TerserPlugin = require('terser-webpack-plugin'); -module.exports = { - mode: 'development', - devtool: 'inline-source-map', - entry: { - main: './index.ts', +module.exports = [ + { + mode: 'development', + devtool: 'inline-source-map', + entry: { + main: './index.ts', + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: 'ods-charts.js', + libraryTarget: 'umd', + library: 'ODSCharts', + }, + resolve: { + extensions: ['.ts', '.tsx', '.js'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + loader: 'ts-loader', + }, + ], + }, }, - output: { - path: path.resolve(__dirname, './dist'), - filename: 'ods-charts.js', - libraryTarget: 'umd', - library: 'ODSCharts', + { + mode: 'development', + devtool: false, + entry: { + main: './index.ts', + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: 'ods-charts.min.js', + libraryTarget: 'umd', + library: 'ODSCharts', + }, + resolve: { + extensions: ['.ts', '.tsx', '.js'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + loader: 'ts-loader', + }, + ], + }, + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + format: { + comments: false, + preamble: `/*! + * Software Name: Orange Design System Charts + * SPDX-FileCopyrightText: Copyright (c) 2023 - 2024 Orange SA + * SPDX-License-Identifier: MIT + * + * This software is distributed under the MIT license. + */ + `, + }, + }, + extractComments: false, + }), + ], + }, }, - resolve: { - extensions: ['.ts', '.tsx', '.js'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - }, - ], - }, -}; +];