Configuration API
To integrate with other tools, it's useful to have access to the configuration generated by CRACO.
The CRACO Configuration API supports Jest and Webpack.
Jest
createJestConfig(cracoConfig, context = {}, options = { verbose: false, config: null })
A CRACO config, a JEST context object, and an options object ({ verbose?: boolean, config?: string }
) are taken as arguments and the generated Jest config object is returned.
createJestConfig
does not accept cracoConfig
as a function. If your craco.config.js
exposes a config function, you have to call it yourself before using it here.
const { createJestConfig } = require('@craco/craco');
const cracoConfig = require('./craco.config.js');
const jestConfig = createJestConfig(cracoConfig);
module.exports = jestConfig;
Webpack
createWebpackDevConfig(cracoConfig, context = {}, options = { verbose: false, config: null })
createWebpackProdConfig(cracoConfig, context = {}, options = { verbose: false, config: null })
createWebpackDevConfig
and createWebpackProdConfig
do not accept cracoConfig
as a function. If your craco.config.js
exposes a config function, you have to call it yourself before using it here.
const { createWebpackDevConfig } = require('@craco/craco');
const cracoConfig = require('./craco.config.js');
const webpackConfig = createWebpackDevConfig(cracoConfig);
module.exports = webpackConfig;