-
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.
feat(rspack): Update configuration generator to support NxRspackAppPl…
…ugin (#29024) WIP <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: Colum Ferry <[email protected]>
- Loading branch information
1 parent
a1efb63
commit 5bd8f4f
Showing
9 changed files
with
410 additions
and
188 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
53 changes: 53 additions & 0 deletions
53
packages/react/src/generators/application/files/base-rspack/rspack.config.js__tmpl__
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,53 @@ | ||
<%_ if (rspackPluginOptions) { _%> | ||
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin'); | ||
const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin'); | ||
const { join } = require('path'); | ||
|
||
module.exports = { | ||
output: { | ||
path: join(__dirname, '<%= offsetFromRoot %><%= rspackPluginOptions.outputPath %>'), | ||
}, | ||
devServer: { | ||
port: 4200, | ||
historyApiFallback: { | ||
index: '/index.html', | ||
disableDotRule: true, | ||
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'], | ||
}, | ||
}, | ||
plugins: [ | ||
new NxAppRspackPlugin({ | ||
tsConfig: '<%= rspackPluginOptions.tsConfig %>', | ||
main: '<%= rspackPluginOptions.main %>', | ||
index: '<%= rspackPluginOptions.index %>', | ||
baseHref: '<%= rspackPluginOptions.baseHref %>', | ||
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>, | ||
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>, | ||
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none', | ||
optimization: process.env['NODE_ENV'] === 'production', | ||
}), | ||
new NxReactRspackPlugin({ | ||
// Uncomment this line if you don't want to use SVGR | ||
// See: https://react-svgr.com/ | ||
// svgr: false | ||
}), | ||
], | ||
}; | ||
<%_ } else { _%> | ||
const { composePlugins, withNx, withReact } = require('@nx/rspack'); | ||
|
||
// Nx plugins for rspack. | ||
module.exports = composePlugins( | ||
withNx(), | ||
withReact({ | ||
// Uncomment this line if you don't want to use SVGR | ||
// See: https://react-svgr.com/ | ||
// svgr: false | ||
}), | ||
(config) => { | ||
// Update the rspack config as needed here. | ||
// e.g. `config.plugins.push(new MyPlugin())` | ||
return config; | ||
} | ||
); | ||
<%_ } _%> |
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
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
Oops, something went wrong.