@@ -2,13 +2,19 @@ import * as webpack from 'webpack';
2
2
import * as path from 'path' ;
3
3
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
4
4
const SubresourceIntegrityPlugin = require ( 'webpack-subresource-integrity' ) ;
5
-
5
+ import { LicenseWebpackPlugin } from 'license-webpack-plugin' ;
6
6
import { generateEntryPoints , packageChunkSort } from '../../utilities/package-chunk-sort' ;
7
7
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack' ;
8
8
import { IndexHtmlWebpackPlugin } from '../../plugins/index-html-webpack-plugin' ;
9
9
import { extraEntryParser , lazyChunksFilter } from './utils' ;
10
10
import { WebpackConfigOptions } from '../webpack-config' ;
11
11
12
+ /**
13
+ * license-webpack-plugin has a peer dependency on webpack-sources, list it in a comment to
14
+ * let the dependency validator know it is used.
15
+ *
16
+ * require('webpack-sources')
17
+ */
12
18
13
19
export function getBrowserConfig ( wco : WebpackConfigOptions ) {
14
20
const { projectRoot, buildOptions, appConfig } = wco ;
@@ -68,6 +74,15 @@ export function getBrowserConfig(wco: WebpackConfigOptions) {
68
74
} ) ) ;
69
75
}
70
76
77
+ if ( buildOptions . extractLicenses ) {
78
+ extraPlugins . push ( new LicenseWebpackPlugin ( {
79
+ pattern : / ^ ( M I T | I S C | B S D .* ) $ / ,
80
+ suppressErrors : true ,
81
+ perChunkOutput : false ,
82
+ outputFilename : `3rdpartylicenses.txt`
83
+ } ) ) ;
84
+ }
85
+
71
86
const globalStylesEntries = extraEntryParser ( appConfig . styles , appRoot , 'styles' )
72
87
. map ( style => style . entry ) ;
73
88
0 commit comments