create-react-app-hack
create-react-app-hack copied to clipboard
Step 1 — Switch from React to Preact
It's time to get hacking!
The main idea here is that we alias react* modules with their preact* equivalents and pull in preact-compat to make sure the API stays the same. This is done both for Node and webpack.
For testing, it's a bit trickier, we pull in preact-render-to-json and put it on the global scope to be available in all tests.
Due to babel-preset-react, we need to remove __self and __source from the output JSON to be able to reliably use snapshot testing in jest.
File sizes:
| File name | Before gzip | After gzip |
|---|---|---|
| build/static/js/main.d722544c.js | 38.22 kB | 13.12 kB |
Source Map Analyzer output:
