-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): ensure rspack react app is added to exclude on rspack plu…
…gin #28464
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/react/src/generators/application/lib/add-project-root-to-rspack-plugin-excludes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { joinPathFragments, Tree, updateNxJson } from '@nx/devkit'; | ||
import { readNxJson } from '@nx/devkit'; | ||
|
||
export function addProjectRootToRspackPluginExcludesIfExists( | ||
tree: Tree, | ||
projectRoot: string | ||
) { | ||
const excludeProjectGlob = joinPathFragments(projectRoot, '/**'); | ||
const nxJson = readNxJson(tree); | ||
if (!nxJson.plugins?.length) { | ||
return; | ||
} | ||
for (let i = 0; i < nxJson.plugins.length; i++) { | ||
let plugin = nxJson.plugins[i]; | ||
const isRspackPlugin = | ||
typeof plugin === 'string' | ||
? plugin === '@nx/rspack/plugin' | ||
: plugin.plugin === '@nx/rspack/plugin'; | ||
if (isRspackPlugin) { | ||
if (typeof plugin === 'string') { | ||
plugin = { | ||
plugin: plugin, | ||
exclude: [excludeProjectGlob], | ||
}; | ||
} else { | ||
plugin.exclude = [...(plugin.exclude ?? []), excludeProjectGlob]; | ||
} | ||
nxJson.plugins[i] = plugin; | ||
} | ||
} | ||
updateNxJson(tree, nxJson); | ||
} |