From 1c7cd95918cf108df0371e6439a6f2ab9e71b2fb Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Mon, 22 Jul 2024 10:35:08 +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', - }, - ], - }, -}; +];