cra-rewired
You can add loaders or change other webpack configs without npm run eject
from create-react-app
Examples
Quick Overview
create-react-app my-appcd my-appnpm install cra-rewired --save-devecho "SKIP_PREFLIGHT_CHECK=true" >> .env
Then create a custom options file. This example adds a loader that loads the contents of the yaml file json.
// webpack.custom.jsmodule { return // path in webpack.config 'module.rules...oneOf': // operation: $unshift | $push | $set $unshift: test: /\.$/ include: pathsappSrc use: 'json-loader' 'yaml-loader' ;};
Update scripts.start
in package.json
as follows.
{
...
"scripts": {
"start_old": "react-scripts start",
"start": "cra-rewired -s react-scripts -m start -c webpack.custom.js",
...
},
...
}
Now you can import yaml file contents.
; console; // { message: 'hello world' }