-
Notifications
You must be signed in to change notification settings - Fork 32
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
Slim down the React build #119
Comments
@ustun Thanks for opening this issue. We realize this is a problem with the React template and will open a work item on our end to address this issue in the near future Thanks, Courtney |
Having the same issue, I partially solved by removing the "vendors" entry in webpack.config.js as stated in the webpack 4 official documentation. I tried adding the following config: optimization: {
splitChunks: { chunks: "all" },
runtimeChunk: true,
}, but it broke my app. For now I'm happy enough using a single chunk with everything in it. |
Removing the whole After that, selective imports of Button ( |
Selective imports worked and shrank everything way down for me. Strangely enough, this is how Microsoft recommends using the fabric ui library in some guides. You just need to be careful to do it everywhere in your project. Also, you don't need to remove the whole This way I got from:
down to:
|
I've recently done some improvement here, but I'll check if there is more to be done. |
I created a brand new React-TypeScript addin using the yo office generator. The sample project, without any changes results in almost 3 MB of JS output. This seems like an important problem since I assume a lot of people will be starting with this generator, and we might see big addins that might slow down Office apps.
Here is what npm run build displays:
Summary of Problems:
I enabled the webpack-bundle-analyzer https://www.npmjs.com/package/webpack-bundle-analyzer and here is the report it generated on the production build:
Some suggestions for improvement:
import { Button, ButtonType } from "office-ui-fabric-react";
to
import { Button, ButtonType } from "office-ui-fabric-react/lib/Button";
it seems to just import the Button. I think webpack should be handling this, but there is something lost in translation, so this optimization is not done automatically for some reason.
The text was updated successfully, but these errors were encountered: