File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ const path = require('path')
9
9
const { RawSource } = require ( 'webpack-sources' )
10
10
const loaderUtils = require ( 'loader-utils' )
11
11
const cssReplace = require ( './css-replace' )
12
- const webpack = require ( 'webpack' )
13
12
14
- const webpackMajorVersion = Number ( webpack . version . split ( '.' ) [ 0 ] )
15
13
const isCSS = ( name ) => / \. c s s $ / . test ( name )
16
14
// const strip = (str) => str.replace(/\/$/, '')
17
15
@@ -66,9 +64,11 @@ class CssUrlRelativePlugin {
66
64
}
67
65
68
66
applyCompilation = ( compilation ) => {
67
+ // webpack5 新加的 hook
68
+ const isWebpack5 = compilation . hooks . processAssets !== undefined
69
69
// webpack version <= 4
70
- if ( webpackMajorVersion <= 4 ) {
71
- compilation . hooks . optimizeChunkAssets . tapAsync ( plugin , ( chunks , done ) => {
70
+ if ( ! isWebpack5 ) {
71
+ compilation . hooks . optimizeChunkAssets . tapAsync ( this . plugin , ( chunks , done ) => {
72
72
this . fixCssUrl ( compilation , chunks , done )
73
73
} )
74
74
return ;
You can’t perform that action at this time.
0 commit comments