Skip to content

Commit 95ae268

Browse files
committed
fix: Also extract comments for spdx license information
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent a8b6d8e commit 95ae268

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

webpack.common.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ module.exports = {
147147
},
148148

149149
optimization: {
150+
minimizer: [{
151+
apply: (compiler) => {
152+
// Lazy load the Terser plugin
153+
const TerserPlugin = require('terser-webpack-plugin')
154+
new TerserPlugin({
155+
extractComments: {
156+
condition: /^\**!|@license|@copyright|@spdx/i,
157+
filename: (fileData) => {
158+
// The "fileData" argument contains object with "filename", "basename", "query" and "hash"
159+
return `${fileData.filename}.license${fileData.query}`
160+
},
161+
},
162+
terserOptions: {
163+
compress: {
164+
passes: 2,
165+
},
166+
},
167+
}).apply(compiler)
168+
},
169+
}],
150170
splitChunks: {
151171
automaticNameDelimiter: '-',
152172
minChunks: 3, // minimum number of chunks that must share the module

0 commit comments

Comments
 (0)