-
-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimize the bundle size #35
Comments
I think it should be possible to do this manually.
import Konva from 'konva/src/Core';
// now you have Konva object with Stage, Layer, FastLayer, Group, Shape and some additional utils function
// so there are no shapes (rect, circle, etc), no filters, no d&d support.
// but you can simply add anything you need:
import 'konva/src/shapes/rect';
//now Konva.Rect is available to use I didn't test that. But in theory, should work. It will be nice to have a better way. Any ideas are welcome. |
Modules should be separated, and those individual modules should require only what they depend on. I'm doing some preliminary testing with this library and if it works well with my codebase I can take a stab at this. |
To solve this I created the file /**
* In webpack config should be defined:
* alias: {
* "konva": path.resolve(ROOT, "./custom-konva.js"),
* },
*/
var Konva = require("./node_modules/konva/src/Core");
require("./node_modules/konva/src/Animation");
require("./node_modules/konva/src/Tween");
require("./node_modules/konva/src/DragAndDrop");
require("./node_modules/konva/src/shapes/Circle");
require("./node_modules/konva/src/shapes/Line");
require("./node_modules/konva/src/shapes/Path");
require("./node_modules/konva/src/shapes/Rect");
require("./node_modules/konva/src/shapes/Text");
module.exports = Konva; |
is there anyway to do this with rollup? It looks the |
Just implemented minimal version bundle, so it should work without extra config from bundlers. It is available with // load minimal version of 'react-konva`
import { Stage, Layer, Rect } from "react-konva/lib/ReactKonvaCore";
// minimal version has to support for core shapes and filters
// if you want import a shape into Konva namespace you can just do this:
import "konva/lib/shapes/Rect"; Demo: https://codesandbox.io/s/6l97wny44z More info: https://github.com/konvajs/react-konva#minimal-bundle Have a question? Ask here. |
Hello.
I found out
react-konva
always imports wholekonva
package. It highly increases webpack bundle size.Is it possible to require only necessary sources?
Thank you.
The text was updated successfully, but these errors were encountered: