Skip to content

Instantly share code, notes, and snippets.

@char0n
Last active May 5, 2022 21:47
Show Gist options
  • Save char0n/40bdff68805a7e3b86e35c417cc0b326 to your computer and use it in GitHub Desktop.
Save char0n/40bdff68805a7e3b86e35c417cc0b326 to your computer and use it in GitHub Desktop.
Create React App override for start script using rewire library
const path = require('path');
const rewire = require('rewire');
process.chdir(path.join(__dirname, '..'));
const start = rewire('react-scripts/scripts/start.js')
const configFactory = start.__get__('configFactory');
const configFactoryMock = (webpackEnv) => {
const config = configFactory(webpackEnv);
// display errors for child compilations
config.stats = {
...config.stats,
children: true
};
return config;
}
start.__set__('configFactory', configFactoryMock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment