Skip to content

Commit 7275ae4

Browse files
clarkdohaoqunjiang
authored andcommitted
feat: support webpack 5 hooks (#1469)
1 parent d7024d1 commit 7275ae4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/plugin.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ class VueLoaderPlugin {
1010
if (compiler.hooks) {
1111
// webpack 4
1212
compiler.hooks.compilation.tap(id, compilation => {
13-
compilation.hooks.normalModuleLoader.tap(id, loaderContext => {
13+
let normalModuleLoader
14+
if (Object.isFrozen(compilation.hooks)) {
15+
// webpack 5
16+
normalModuleLoader = require('webpack/lib/NormalModule').getCompilationHooks(compilation).loader
17+
} else {
18+
normalModuleLoader = compilation.hooks.normalModuleLoader
19+
}
20+
normalModuleLoader.tap(id, loaderContext => {
1421
loaderContext[NS] = true
1522
})
1623
})

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"peerDependencies": {
3636
"css-loader": "*",
37-
"webpack": "^4.1.0"
37+
"webpack": "^4.1.0 || ^5.0.0-0"
3838
},
3939
"dependencies": {
4040
"@vue/component-compiler-utils": "^2.4.0",

0 commit comments

Comments
 (0)