@nx/react
Version:
28 lines (27 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.withReact = withReact;
const apply_react_config_1 = require("./nx-react-webpack-plugin/lib/apply-react-config");
const deprecation_1 = require("../src/utils/deprecation");
const processed = new Set();
/**
* @deprecated Will be removed in Nx v24. Use `NxReactWebpackPlugin` from
* `@nx/react/webpack-plugin` in a standard webpack config and run
* `nx g @nx/webpack:convert-to-inferred`. See
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
* @param {WithReactOptions} pluginOptions
* @returns {NxWebpackPlugin}
*/
function withReact(pluginOptions = {}) {
(0, deprecation_1.warnReactWithReactDeprecation)();
return function configure(config, context) {
const { withWeb } = require('@nx/webpack');
if (processed.has(config))
return config;
// Apply web config for CSS, JSX, index.html handling, etc.
config = withWeb(pluginOptions)(config, context);
(0, apply_react_config_1.applyReactConfig)({}, config);
processed.add(config);
return config;
};
}