Skip to content

Commit

Permalink
feat: Support proxied loaders w/ getLoadersByName() is user config (#…
Browse files Browse the repository at this point in the history
…1761)

* feat: Support proxied loaders w/ `getLoadersByName()`

* docs: Adding changeset
  • Loading branch information
rschristian authored Dec 22, 2022
1 parent 712ae26 commit fb100b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-ducks-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Support proxied loaders w/ `getLoadersByName()` method in users' `preact.config.js`
12 changes: 7 additions & 5 deletions packages/cli/src/lib/webpack/transform-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ class WebpackConfigHelpers {
: [{ rule, ruleIndex, loader: loaders, loaderIndex: -1 }]
)
.reduce((arr, loaders) => arr.concat(loaders), [])
.filter(
({ loader }) =>
(typeof loader === 'string' && loader.includes(name)) ||
(typeof loader.loader === 'string' && loader.loader.includes(name))
);
.filter(({ loader }) => {
if (typeof loader === 'string') return loader.includes(name);
return typeof loader.loader === 'string' &&
loader.loader.includes('proxy-loader')
? loader.options.loader.includes(name)
: loader.loader.includes(name);
});
}

/**
Expand Down

0 comments on commit fb100b3

Please sign in to comment.