For my case, I'm using a custom build fabric js version 5.2.4 with an Ionic 6 application.
- Uninstall fabric js if you are installed it in your project with
npm uninstall fabric
- Download your custom build from fabric js site : http://fabricjs.com/build/
- Add the downloaded file to
public
directory. For example public/libs/fabric/fabric.min.js
- At
App.js
useEffect(() => {
const script = document.createElement('script');
// You may have to replace this code with your path.
script.src = "libs/fabric/fabric.min.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, []);
- re-serve project.
- Now
fabric
should be available from window.fabric
Note.
The editor also add some code to my tsconfig.json
"include": [
"src",
"public/libs" // This code
]
I do not know what it does but it works fine so I leave it.