Skip to content

Commit

Permalink
feat: support webpack 5 hooks (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and sodatea committed Jan 10, 2019
1 parent d7024d1 commit 7275ae4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ class VueLoaderPlugin {
if (compiler.hooks) {
// webpack 4
compiler.hooks.compilation.tap(id, compilation => {
compilation.hooks.normalModuleLoader.tap(id, loaderContext => {
let normalModuleLoader
if (Object.isFrozen(compilation.hooks)) {
// webpack 5
normalModuleLoader = require('webpack/lib/NormalModule').getCompilationHooks(compilation).loader
} else {
normalModuleLoader = compilation.hooks.normalModuleLoader
}
normalModuleLoader.tap(id, loaderContext => {
loaderContext[NS] = true
})
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"peerDependencies": {
"css-loader": "*",
"webpack": "^4.1.0"
"webpack": "^4.1.0 || ^5.0.0-0"
},
"dependencies": {
"@vue/component-compiler-utils": "^2.4.0",
Expand Down

0 comments on commit 7275ae4

Please sign in to comment.