@@ -93,7 +93,9 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
93
93
webpack ( compiler ) {
94
94
const Compilation = compiler . webpack . Compilation
95
95
const { ConcatSource } = compiler . webpack . sources
96
-
96
+ function getEmitAssetPath ( outputPath : string , file : string ) {
97
+ return path . relative ( compiler . context , path . resolve ( outputPath , file ) )
98
+ }
97
99
compiler . hooks . compilation . tap ( pluginName , ( compilation ) => {
98
100
compilation . hooks . processAssets . tap (
99
101
{
@@ -122,11 +124,14 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
122
124
groupedEntries . js . forEach ( ( [ file , source ] ) => {
123
125
js . set ( file , source )
124
126
} )
125
- outputCachedMap . set ( compiler . outputPath , {
126
- css,
127
- html,
128
- js
129
- } )
127
+ if ( js . size || css . size || html . size ) {
128
+ outputCachedMap . set ( compiler . outputPath , {
129
+ css,
130
+ html,
131
+ js
132
+ } )
133
+ }
134
+
130
135
return
131
136
}
132
137
@@ -149,7 +154,7 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
149
154
runtimeSet
150
155
} )
151
156
const source = new ConcatSource ( html )
152
- compilation . emitAsset ( path . resolve ( key , file ) , source )
157
+ compilation . emitAsset ( getEmitAssetPath ( key , file ) , source )
153
158
} )
154
159
html . clear ( )
155
160
}
@@ -175,7 +180,7 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
175
180
classGenerator
176
181
} ) . code
177
182
const source = new ConcatSource ( code )
178
- compilation . emitAsset ( path . resolve ( key , file ) , source )
183
+ compilation . emitAsset ( getEmitAssetPath ( key , file ) , source )
179
184
} )
180
185
js . clear ( )
181
186
}
@@ -201,7 +206,7 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
201
206
runtimeSet
202
207
} )
203
208
const source = new ConcatSource ( newCss )
204
- compilation . emitAsset ( path . resolve ( key , file ) , source )
209
+ compilation . emitAsset ( getEmitAssetPath ( key , file ) , source )
205
210
} )
206
211
css . clear ( )
207
212
}
0 commit comments