@@ -93,10 +93,10 @@ class WindiCSSWebpackPlugin {
93
93
*/
94
94
compiler . options . module . rules . push ( {
95
95
include ( resource ) {
96
- if ( shouldExcludeResource ( resource ) )
96
+ if ( ! compiler . $windi || shouldExcludeResource ( resource ) )
97
97
return false
98
98
99
- return Boolean ( compiler . $windyCSSService . isDetectTarget ( resource ) )
99
+ return Boolean ( compiler . $windi . isDetectTarget ( resource ) )
100
100
} ,
101
101
enforce : 'post' ,
102
102
use : [ {
@@ -111,10 +111,10 @@ class WindiCSSWebpackPlugin {
111
111
*/
112
112
compiler . options . module . rules . push ( {
113
113
include ( resource ) {
114
- if ( shouldExcludeResource ( resource ) )
114
+ if ( ! compiler . $windi || shouldExcludeResource ( resource ) )
115
115
return false
116
116
117
- return Boolean ( compiler . $windyCSSService . isDetectTarget ( resource ) )
117
+ return Boolean ( compiler . $windi . isDetectTarget ( resource ) )
118
118
} ,
119
119
use : [ {
120
120
loader : transformTemplateLoader ,
@@ -123,10 +123,10 @@ class WindiCSSWebpackPlugin {
123
123
124
124
compiler . options . module . rules . push ( {
125
125
include ( resource ) {
126
- if ( shouldExcludeResource ( resource ) )
126
+ if ( ! compiler . $windi || shouldExcludeResource ( resource ) )
127
127
return false
128
128
129
- return Boolean ( compiler . $windyCSSService . isCssTransformTarget ( resource ) )
129
+ return Boolean ( compiler . $windi . isCssTransformTarget ( resource ) )
130
130
} ,
131
131
use : [ {
132
132
loader : transformCSSLoader ,
@@ -150,7 +150,7 @@ class WindiCSSWebpackPlugin {
150
150
* Add the windycss config file as a dependency so that the watcher can handle updates to it.
151
151
*/
152
152
compiler . hooks . afterCompile . tap ( NAME , ( compilation ) => {
153
- if ( compiler . $windyCSSService ) {
153
+ if ( compiler . $windi ) {
154
154
let hasConfig = false
155
155
// add watcher for the config path
156
156
for ( const name of defaultConfigureFiles ) {
@@ -191,27 +191,27 @@ class WindiCSSWebpackPlugin {
191
191
resource = 'all-modules'
192
192
193
193
// make sure service is available and file is valid
194
- if ( ! compiler . $windyCSSService || shouldExcludeResource ( resource ) )
194
+ if ( ! compiler . $windi || shouldExcludeResource ( resource ) )
195
195
return
196
196
197
197
const skipInvalidation
198
- = compiler . $windyCSSService . dirty . has ( resource )
199
- || ( resource !== 'all-modules' && ! compiler . $windyCSSService . isDetectTarget ( resource ) && resource !== compiler . $windyCSSService . configFilePath )
198
+ = compiler . $windi . dirty . has ( resource )
199
+ || ( resource !== 'all-modules' && ! compiler . $windi . isDetectTarget ( resource ) && resource !== compiler . $windi . configFilePath )
200
200
201
201
debug . plugin ( 'file update' , resource , `skip:${ skipInvalidation } ` )
202
202
if ( skipInvalidation )
203
203
return
204
204
// Add dirty file so the loader can process it
205
- compiler . $windyCSSService . dirty . add ( resource )
205
+ compiler . $windi . dirty . add ( resource )
206
206
// Trigger a change to the virtual module
207
207
const moduleUpdateId = hmrId ++
208
208
MODULE_ID_VIRTUAL_MODULES . forEach ( ( virtualModulePath ) => {
209
209
let virtualModuleContent = ''
210
210
const match = virtualModulePath . match ( MODULE_ID_VIRTUAL_TEST )
211
211
if ( match ) {
212
212
const layer = ( match [ 1 ] as LayerName | 'all' ) || 'all'
213
- if ( compiler . $windyCSSService && compiler . $windyCSSService . virtualModules . has ( layer ) )
214
- virtualModuleContent = def ( compiler . $windyCSSService . virtualModules . get ( layer ) , '' )
213
+ if ( compiler . $windi && compiler . $windi . virtualModules . has ( layer ) )
214
+ virtualModuleContent = def ( compiler . $windi . virtualModules . get ( layer ) , '' )
215
215
}
216
216
virtualModules . writeModule (
217
217
join ( this . options . virtualModulePath , virtualModulePath ) ,
@@ -223,13 +223,13 @@ class WindiCSSWebpackPlugin {
223
223
224
224
// Make windy service available to the loader
225
225
const initWindyCSSService = async ( ) => {
226
- if ( ! compiler . $windyCSSService ) {
226
+ if ( ! compiler . $windi ) {
227
227
const utils = def ( this . options . utils , createUtils ( this . options , {
228
228
root,
229
229
name : NAME ,
230
230
} ) )
231
231
232
- compiler . $windyCSSService = Object . assign (
232
+ compiler . $windi = Object . assign (
233
233
utils ,
234
234
{
235
235
root,
@@ -240,25 +240,25 @@ class WindiCSSWebpackPlugin {
240
240
// Scans all files and builds initial css
241
241
// wrap in a try catch
242
242
try {
243
- await compiler . $windyCSSService . init ( )
243
+ await compiler . $windi . init ( )
244
244
}
245
245
catch ( e : any ) {
246
- compiler . $windyCSSService . initException = e
246
+ compiler . $windi . initException = e
247
247
}
248
248
}
249
249
}
250
250
251
251
compiler . hooks . thisCompilation . tap ( NAME , ( compilation ) => {
252
- if ( ! compiler . $windyCSSService )
252
+ if ( ! compiler . $windi )
253
253
return
254
254
255
255
// give the init exception to the compilation so that the user can see there was an issue
256
- if ( compiler . $windyCSSService . initException ) {
257
- compilation . errors . push ( compiler . $windyCSSService . initException )
258
- compiler . $windyCSSService . initException = undefined
256
+ if ( compiler . $windi . initException ) {
257
+ compilation . errors . push ( compiler . $windi . initException )
258
+ compiler . $windi . initException = undefined
259
259
}
260
260
compilation . hooks . childCompiler . tap ( NAME , ( childCompiler ) => {
261
- childCompiler . $windyCSSService = compiler . $windyCSSService
261
+ childCompiler . $windi = compiler . $windi
262
262
} )
263
263
} )
264
264
0 commit comments