react-scripts version: 1.1.0
The official react-scripts that is included in Create React App does not allow any custom webpack configuration, which leads to people using more eject
than we wanted to.
Allow users to extend webpack configuration.
create-react-app APP_NAME_HERE --scripts-version extensible-react-scripts
Edit the cra.config.js
file generated at the root of the project.
yarn remove react-scripts
yarn add --dev extensible-react-scripts
- Create a file named
cra.config.js
at the root of the project (outsidesrc
folder) exporting a function like below:
module.exports = {
webpack: function(webpackConfig, { isDevelopment }) {
// modify webpack config here
const config = Object.assign({}, webpackConfig)
// return the modified version
return config
},
}
That's it!
Config | Format | Return type |
---|---|---|
paths | function(paths, { isDevelopment, resolvePath }) |
Object |
webpack | function(webpackConfig, { isDevelopment, paths, resolvePath }) |
Object |
The version will be the same of the official react-scripts
. Check package.json or the top of this file.
react-app-rewired by @timarney
configurable-react-scripts by @svrcekmichal
Bruno Lemos (@brunolemos on twitter)