1
- import * as os from 'os' ;
1
+ import * as os from "os" ;
2
2
3
- import { SourceMapConsumer } from ' source-map' ;
4
- import { validate } from ' schema-utils' ;
5
- import serialize from ' serialize-javascript' ;
6
- import pLimit from ' p-limit' ;
7
- import { Worker } from ' jest-worker' ;
3
+ import { SourceMapConsumer } from " source-map" ;
4
+ import { validate } from " schema-utils" ;
5
+ import serialize from " serialize-javascript" ;
6
+ import pLimit from " p-limit" ;
7
+ import { Worker } from " jest-worker" ;
8
8
9
- import { cssnanoMinify , cssoMinify , cleanCssMinify } from ' ./utils' ;
9
+ import { cssnanoMinify , cssoMinify , cleanCssMinify } from " ./utils" ;
10
10
11
- import * as schema from ' ./options.json' ;
12
- import { minify as minifyFn } from ' ./minify' ;
11
+ import * as schema from " ./options.json" ;
12
+ import { minify as minifyFn } from " ./minify" ;
13
13
14
14
const warningRegex = / \s .+ : + ( [ 0 - 9 ] + ) : + ( [ 0 - 9 ] + ) / ;
15
15
16
16
class CssMinimizerPlugin {
17
17
constructor ( options = { } ) {
18
18
validate ( schema , options , {
19
- name : ' Css Minimizer Plugin' ,
20
- baseDataPath : ' options' ,
19
+ name : " Css Minimizer Plugin" ,
20
+ baseDataPath : " options" ,
21
21
} ) ;
22
22
23
23
const {
@@ -49,7 +49,7 @@ class CssMinimizerPlugin {
49
49
input . version &&
50
50
input . sources &&
51
51
Array . isArray ( input . sources ) &&
52
- typeof input . mappings === ' string'
52
+ typeof input . mappings === " string"
53
53
) ;
54
54
}
55
55
@@ -72,8 +72,8 @@ class CssMinimizerPlugin {
72
72
original . column
73
73
} ][${ name } :${ error . line } ,${ error . column } ]${
74
74
error . stack
75
- ? `\n${ error . stack . split ( '\n' ) . slice ( 1 ) . join ( '\n' ) } `
76
- : ''
75
+ ? `\n${ error . stack . split ( "\n" ) . slice ( 1 ) . join ( "\n" ) } `
76
+ : ""
77
77
} `
78
78
) ;
79
79
builtError . file = name ;
@@ -85,7 +85,7 @@ class CssMinimizerPlugin {
85
85
`${ name } from Css Minimizer \n${ error . message } [${ name } :${ error . line } ,${
86
86
error . column
87
87
} ]${
88
- error . stack ? `\n${ error . stack . split ( '\n' ) . slice ( 1 ) . join ( '\n' ) } ` : ''
88
+ error . stack ? `\n${ error . stack . split ( "\n" ) . slice ( 1 ) . join ( "\n" ) } ` : ""
89
89
} `
90
90
) ;
91
91
builtError . file = name ;
@@ -114,7 +114,7 @@ class CssMinimizerPlugin {
114
114
warningsFilter
115
115
) {
116
116
let warningMessage = warning ;
117
- let locationMessage = '' ;
117
+ let locationMessage = "" ;
118
118
let source ;
119
119
120
120
if ( sourceMap ) {
@@ -136,7 +136,7 @@ class CssMinimizerPlugin {
136
136
) {
137
137
( { source } = original ) ;
138
138
139
- warningMessage = `${ warningMessage . replace ( warningRegex , '' ) } ` ;
139
+ warningMessage = `${ warningMessage . replace ( warningRegex , "" ) } ` ;
140
140
locationMessage = `${ requestShortener . shorten ( original . source ) } :${
141
141
original . line
142
142
} :${ original . column } `;
@@ -162,10 +162,10 @@ class CssMinimizerPlugin {
162
162
}
163
163
164
164
async optimize ( compiler , compilation , assets , optimizeOptions ) {
165
- const cache = compilation . getCache ( ' CssMinimizerWebpackPlugin' ) ;
165
+ const cache = compilation . getCache ( " CssMinimizerWebpackPlugin" ) ;
166
166
let numberOfAssetsForMinify = 0 ;
167
167
const assetsForMinify = await Promise . all (
168
- Object . keys ( typeof assets === ' undefined' ? compilation . assets : assets )
168
+ Object . keys ( typeof assets === " undefined" ? compilation . assets : assets )
169
169
. filter ( ( name ) => {
170
170
const { info } = compilation . getAsset ( name ) ;
171
171
@@ -219,7 +219,7 @@ class CssMinimizerPlugin {
219
219
return initializedWorker ;
220
220
}
221
221
222
- initializedWorker = new Worker ( require . resolve ( ' ./minify' ) , {
222
+ initializedWorker = new Worker ( require . resolve ( " ./minify" ) , {
223
223
numWorkers : numberOfWorkers ,
224
224
enableWorkerThreads : true ,
225
225
} ) ;
@@ -228,13 +228,13 @@ class CssMinimizerPlugin {
228
228
const workerStdout = initializedWorker . getStdout ( ) ;
229
229
230
230
if ( workerStdout ) {
231
- workerStdout . on ( ' data' , ( chunk ) => process . stdout . write ( chunk ) ) ;
231
+ workerStdout . on ( " data" , ( chunk ) => process . stdout . write ( chunk ) ) ;
232
232
}
233
233
234
234
const workerStderr = initializedWorker . getStderr ( ) ;
235
235
236
236
if ( workerStderr ) {
237
- workerStderr . on ( ' data' , ( chunk ) => process . stderr . write ( chunk ) ) ;
237
+ workerStderr . on ( " data" , ( chunk ) => process . stderr . write ( chunk ) ) ;
238
238
}
239
239
240
240
return initializedWorker ;
@@ -348,7 +348,7 @@ class CssMinimizerPlugin {
348
348
constructor ( message ) {
349
349
super ( message ) ;
350
350
351
- this . name = ' Warning' ;
351
+ this . name = " Warning" ;
352
352
this . hideStack = true ;
353
353
this . file = name ;
354
354
}
@@ -397,12 +397,12 @@ class CssMinimizerPlugin {
397
397
398
398
compilation . hooks . statsPrinter . tap ( pluginName , ( stats ) => {
399
399
stats . hooks . print
400
- . for ( ' asset.info.minimized' )
400
+ . for ( " asset.info.minimized" )
401
401
. tap (
402
- ' css-minimizer-webpack-plugin' ,
402
+ " css-minimizer-webpack-plugin" ,
403
403
( minimized , { green, formatFlag } ) =>
404
404
// eslint-disable-next-line no-undefined
405
- minimized ? green ( formatFlag ( ' minimized' ) ) : ''
405
+ minimized ? green ( formatFlag ( " minimized" ) ) : ""
406
406
) ;
407
407
} ) ;
408
408
} ) ;
0 commit comments