Skip to content

Commit

Permalink
feat(vue): support for the loader analysis with vue-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
easy1090 committed Aug 13, 2024
1 parent ec0d240 commit 8e60226
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/build-utils/build/utils/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export function addProbeLoader2Rules<T extends Plugin.BuildRuleSetRule>(
return rules.map((rule) => {
if (!rule || typeof rule === 'string') return rule;

if (fn(rule)) {
if (fn(rule) && !rule.use) {
const _rule = {
...rule,
use: [
Expand All @@ -247,9 +247,10 @@ export function addProbeLoader2Rules<T extends Plugin.BuildRuleSetRule>(

if (rule.use) {
if (Array.isArray(rule.use)) {
const indexList = rule.use.map((_r, index) => {
let indexList: number[] = [];
rule.use.forEach((_r, index) => {
if (fn(_r as T)) {
return index;
indexList.push(index);
}
});

Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-plugin/src/probeLoaderPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ProbeLoaderPlugin {
}

private addProbeLoader(compiler: Plugin.BaseCompiler) {
const rules = compiler.options.module.rules as Plugin.RuleSetRule[];
let rules = compiler.options.module.rules as Plugin.RuleSetRule[];
const appendRule = (rule: Plugin.RuleSetRule, index: number) => {
if ('use' in rule && Array.isArray(rule.use)) {
const _builtinRule = rule.use[index] as Plugin.RuleSetRule;
Expand Down Expand Up @@ -69,12 +69,12 @@ export class ProbeLoaderPlugin {
return;
}

compiler.options.module.rules = Utils.addProbeLoader2Rules(
rules = Utils.addProbeLoader2Rules(
rules,
appendRule,
(r: Plugin.BuildRuleSetRule) =>
Build.Utils.getLoaderNameMatch(r, BuiltinLoaderName, true),
) as RuleSetRules;
) as Plugin.RuleSetRule[];

compiler.options.module.rules = Utils.addProbeLoader2Rules(
rules,
Expand Down

0 comments on commit 8e60226

Please sign in to comment.