aboutsummaryrefslogtreecommitdiffstats
path: root/webpack.common.js
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-07-31 08:50:10 +0200
committerskjnldsv <skjnldsv@protonmail.com>2024-07-31 08:57:18 +0200
commita04c9e6fd89bf1196cdf92efe77a5ca8f2e617b5 (patch)
tree3853d84a069ecc6db232a7068a9e85e315482c27 /webpack.common.js
parent8ff8d9ca19b49161cd2be52d3dbad351634d1bc9 (diff)
downloadnextcloud-server-a04c9e6fd89bf1196cdf92efe77a5ca8f2e617b5.tar.gz
nextcloud-server-a04c9e6fd89bf1196cdf92efe77a5ca8f2e617b5.zip
fix(build): do not run SPDX Plugin in dev mode
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'webpack.common.js')
-rw-r--r--webpack.common.js63
1 files changed, 35 insertions, 28 deletions
diff --git a/webpack.common.js b/webpack.common.js
index e020a5c2904..a3d6efbe955 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -1,3 +1,4 @@
+/* eslint-disable n/no-extraneous-require */
/* eslint-disable camelcase */
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
@@ -16,6 +17,7 @@ const WebpackSPDXPlugin = require('./build/WebpackSPDXPlugin.js')
const modules = require('./webpack.modules.js')
const appVersion = readFileSync('./version.php').toString().match(/OC_VersionString[^']+'([^']+)/)?.[1] ?? 'unknown'
+const isDev = process.env.NODE_ENV === 'development'
const formatOutputFromModules = (modules) => {
// merge all configs into one object, and use AppID to generate the fileNames
@@ -48,7 +50,7 @@ const modulesToBuild = () => {
return formatOutputFromModules(modules)
}
-module.exports = {
+const config = {
entry: modulesToBuild(),
output: {
// Step away from the src folder and extract to the js folder
@@ -149,23 +151,6 @@ module.exports = {
},
optimization: {
- minimizer: [{
- apply: (compiler) => {
- // Lazy load the Terser plugin
- const TerserPlugin = require('terser-webpack-plugin')
- new TerserPlugin({
- extractComments: false,
- terserOptions: {
- format: {
- comments: false,
- },
- compress: {
- passes: 2,
- },
- },
- }).apply(compiler)
- },
- }],
splitChunks: {
automaticNameDelimiter: '-',
minChunks: 3, // minimum number of chunks that must share the module
@@ -238,16 +223,6 @@ module.exports = {
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment\/min$/,
}),
-
- // Generate reuse license files
- new WebpackSPDXPlugin({
- override: {
- select2: 'MIT',
- '@nextcloud/axios': 'GPL-3.0-or-later',
- '@nextcloud/vue': 'AGPL-3.0-or-later',
- 'nextcloud-vue-collections': 'AGPL-3.0-or-later',
- }
- }),
],
externals: {
OC: 'OC',
@@ -274,3 +249,35 @@ module.exports = {
},
},
}
+
+// Generate reuse license files if not in development mode
+if (!isDev) {
+ config.plugins.push(new WebpackSPDXPlugin({
+ override: {
+ select2: 'MIT',
+ '@nextcloud/axios': 'GPL-3.0-or-later',
+ '@nextcloud/vue': 'AGPL-3.0-or-later',
+ 'nextcloud-vue-collections': 'AGPL-3.0-or-later',
+ },
+ }))
+
+ config.optimization.minimizer = [{
+ apply: (compiler) => {
+ // Lazy load the Terser plugin
+ const TerserPlugin = require('terser-webpack-plugin')
+ new TerserPlugin({
+ extractComments: false,
+ terserOptions: {
+ format: {
+ comments: false,
+ },
+ compress: {
+ passes: 2,
+ },
+ },
+ }).apply(compiler)
+ },
+ }]
+}
+
+module.exports = config