9
9
* found in the LICENSE file at https://angular.io/license
10
10
*/
11
11
12
- import { Compiler } from 'webpack' ;
13
- import { RawSource , SourceMapSource } from 'webpack-sources' ;
12
+ import { Compiler , compilation } from 'webpack' ;
13
+ import { RawSource , Source , SourceMapSource } from 'webpack-sources' ;
14
14
15
15
const CleanCSS = require ( 'clean-css' ) ;
16
16
@@ -60,7 +60,7 @@ export class CleanCssWebpackPlugin {
60
60
}
61
61
62
62
apply ( compiler : Compiler ) : void {
63
- hook ( compiler , ( compilation : any , chunks : Array < Chunk > ) => {
63
+ hook ( compiler , ( compilation : compilation . Compilation , chunks : Array < Chunk > ) => {
64
64
const cleancss = new CleanCSS ( {
65
65
compatibility : 'ie9' ,
66
66
level : 2 ,
@@ -80,7 +80,7 @@ export class CleanCssWebpackPlugin {
80
80
const actions = files
81
81
. filter ( file => this . _options . test ( file ) )
82
82
. map ( file => {
83
- const asset = compilation . assets [ file ] ;
83
+ const asset = compilation . assets [ file ] as Source ;
84
84
if ( ! asset ) {
85
85
return Promise . resolve ( ) ;
86
86
}
@@ -100,7 +100,7 @@ export class CleanCssWebpackPlugin {
100
100
}
101
101
102
102
return Promise . resolve ( )
103
- . then ( ( ) => cleancss . minify ( content , map ) )
103
+ . then ( ( ) => map ? cleancss . minify ( content , map ) : cleancss . minify ( content ) )
104
104
. then ( ( output : any ) => {
105
105
let hasWarnings = false ;
106
106
if ( output . warnings && output . warnings . length > 0 ) {
0 commit comments