Skip to content

Commit a04c9e6

Browse files
committed
fix(build): do not run SPDX Plugin in dev mode
Signed-off-by: skjnldsv <[email protected]>
1 parent 8ff8d9c commit a04c9e6

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

webpack.common.js

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable n/no-extraneous-require */
12
/* eslint-disable camelcase */
23
/**
34
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
@@ -16,6 +17,7 @@ const WebpackSPDXPlugin = require('./build/WebpackSPDXPlugin.js')
1617
const modules = require('./webpack.modules.js')
1718

1819
const appVersion = readFileSync('./version.php').toString().match(/OC_VersionString[^']+'([^']+)/)?.[1] ?? 'unknown'
20+
const isDev = process.env.NODE_ENV === 'development'
1921

2022
const formatOutputFromModules = (modules) => {
2123
// merge all configs into one object, and use AppID to generate the fileNames
@@ -48,7 +50,7 @@ const modulesToBuild = () => {
4850
return formatOutputFromModules(modules)
4951
}
5052

51-
module.exports = {
53+
const config = {
5254
entry: modulesToBuild(),
5355
output: {
5456
// Step away from the src folder and extract to the js folder
@@ -149,23 +151,6 @@ module.exports = {
149151
},
150152

151153
optimization: {
152-
minimizer: [{
153-
apply: (compiler) => {
154-
// Lazy load the Terser plugin
155-
const TerserPlugin = require('terser-webpack-plugin')
156-
new TerserPlugin({
157-
extractComments: false,
158-
terserOptions: {
159-
format: {
160-
comments: false,
161-
},
162-
compress: {
163-
passes: 2,
164-
},
165-
},
166-
}).apply(compiler)
167-
},
168-
}],
169154
splitChunks: {
170155
automaticNameDelimiter: '-',
171156
minChunks: 3, // minimum number of chunks that must share the module
@@ -238,16 +223,6 @@ module.exports = {
238223
resourceRegExp: /^\.\/locale$/,
239224
contextRegExp: /moment\/min$/,
240225
}),
241-
242-
// Generate reuse license files
243-
new WebpackSPDXPlugin({
244-
override: {
245-
select2: 'MIT',
246-
'@nextcloud/axios': 'GPL-3.0-or-later',
247-
'@nextcloud/vue': 'AGPL-3.0-or-later',
248-
'nextcloud-vue-collections': 'AGPL-3.0-or-later',
249-
}
250-
}),
251226
],
252227
externals: {
253228
OC: 'OC',
@@ -274,3 +249,35 @@ module.exports = {
274249
},
275250
},
276251
}
252+
253+
// Generate reuse license files if not in development mode
254+
if (!isDev) {
255+
config.plugins.push(new WebpackSPDXPlugin({
256+
override: {
257+
select2: 'MIT',
258+
'@nextcloud/axios': 'GPL-3.0-or-later',
259+
'@nextcloud/vue': 'AGPL-3.0-or-later',
260+
'nextcloud-vue-collections': 'AGPL-3.0-or-later',
261+
},
262+
}))
263+
264+
config.optimization.minimizer = [{
265+
apply: (compiler) => {
266+
// Lazy load the Terser plugin
267+
const TerserPlugin = require('terser-webpack-plugin')
268+
new TerserPlugin({
269+
extractComments: false,
270+
terserOptions: {
271+
format: {
272+
comments: false,
273+
},
274+
compress: {
275+
passes: 2,
276+
},
277+
},
278+
}).apply(compiler)
279+
},
280+
}]
281+
}
282+
283+
module.exports = config

0 commit comments

Comments
 (0)