diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-12 21:37:42 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-06-16 19:06:52 +0200 |
commit | 876beec5a7d4a993c94b2cd47ac28bc2c717ee5f (patch) | |
tree | 2e3bcb532cb91a5b07928dc3c8894d644256f7ff /webpack.common.js | |
parent | 424b51e630890b342093a3225b725e7b9257663d (diff) | |
download | nextcloud-server-876beec5a7d4a993c94b2cd47ac28bc2c717ee5f.tar.gz nextcloud-server-876beec5a7d4a993c94b2cd47ac28bc2c717ee5f.zip |
chore: Add webpack plugin to properly extract licenses used in compiled assets
This will create proper extracted license information for assets and stores it in `fist/file.js.license`.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'webpack.common.js')
-rw-r--r-- | webpack.common.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/webpack.common.js b/webpack.common.js index aa937719f24..3b8da3d948a 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -4,14 +4,16 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ const { VueLoaderPlugin } = require('vue-loader') +const { readFileSync } = require('fs') const path = require('path') + const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except') const webpack = require('webpack') const NodePolyfillPlugin = require('node-polyfill-webpack-plugin') const WorkboxPlugin = require('workbox-webpack-plugin') +const WebpackSPDXPlugin = require('./build/WebpackSPDXPlugin.js') const modules = require('./webpack.modules.js') -const { readFileSync } = require('fs') const appVersion = readFileSync('./version.php').toString().match(/OC_VersionString[^']+'([^']+)/)?.[1] ?? 'unknown' @@ -152,14 +154,11 @@ module.exports = { // Lazy load the Terser plugin const TerserPlugin = require('terser-webpack-plugin') new TerserPlugin({ - extractComments: { - condition: /^\**!|@license|@copyright|SPDX-License-Identifier|SPDX-FileCopyrightText/i, - filename: (fileData) => { - // The "fileData" argument contains object with "filename", "basename", "query" and "hash" - return `${fileData.filename}.license${fileData.query}` - }, - }, + extractComments: false, terserOptions: { + format: { + comments: false, + }, compress: { passes: 2, }, @@ -239,6 +238,13 @@ module.exports = { resourceRegExp: /^\.\/locale$/, contextRegExp: /moment\/min$/, }), + + // Generate reuse license files + new WebpackSPDXPlugin({ + override: { + select2: 'MIT', + } + }), ], externals: { OC: 'OC', |