Skip to content

Commit

Permalink
feat: optimize for Rule.loader
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed May 24, 2023
1 parent 763f7e4 commit 7c180a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/pluginWebpack5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ class VueLoaderPlugin {
if (enableInlineMatchResource) {
// Match rules using `vue-loader`
const vueLoaderRules = rules.filter((rule) => {
const use = rule.use
if (!use) {
return false
}

const matchOnce = (use: RuleSetUse) => {
const matchOnce = (use?: RuleSetUse) => {
let loaderString = ''

if (!use) {
return loaderString
}

if (typeof use === 'string') {
loaderString = use
} else if (Array.isArray(use)) {
Expand All @@ -247,7 +247,7 @@ class VueLoaderPlugin {
return loaderString
}

const loader = matchOnce(use)
const loader = rule.loader || matchOnce(rule.use)
return (
loader === require('../package.json').name ||
loader.startsWith(require.resolve('./index'))
Expand Down

0 comments on commit 7c180a7

Please sign in to comment.