I have a React project that I'd like to convert to Preact to save on the bundle size.
I followed this recommendation, adding the following elements to my code:
Change the package.json
:
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
...and add config-overrides.js
:
const { override, addWebpackAlias } = require('customize-cra');
module.exports = override(
addWebpackAlias({
'react': 'preact/compat',
'react-dom': 'preact/compat'
})
);
Naturally, I also installed preact-compat
and preact
.
When building my app and viewing the components using the Webpack bundle analyzer, I see that react
and react-dom
are still in my bundle.
What am I doing wrong with my implementation?