Info: Fails to build a minified create-react-app with ipfs #1321
Description
There are a lot of issues regarding create-react-app
and js-ipfs
, let's keep that discussion in this one, as well as options to make them play well together.
✅ js-ipfs minified version
The minified version of IPFS (when you run npm run build
and outputs to dist/index.min.js
) wasn't being uglified (compressed and mangled) due to the way we were doing some type checks. This has been solved and will be available in the 0.29.0 release.
ℹ️ create-react-app
For those who are using create-react-app
with IPFS, you'll still encounter some issues when trying to build a production version. The problem comes from create-react-app
itself and not IPFS, because it uses UglifyJS that still doesn't support ES6. As IPFS doesn't offer a transpiled version, trying to build a production version of a CRA with IPFS will fail to minify. A new version of CRA is being worked on, using uglify-es
that supports ES6. Until then, developers have a few options:
- Eject and change the webpack configs to use
uglify-es
intead ofuglify-js
- Until the 0.29.0 release lands, you'll have to follow these configs: Info: Fails to build a minified create-react-app with ipfs #1321 (comment)
- Import the IPFS with a script tag
- After the 0.29.0 release you'll be able to import the bundled & minified version
- Use this trick that @fazo96 pointed out