svelte-materialify 的包大小是多少?

What is the bundle size of svelte-materialify?

我想为我的项目使用 svelte-materialify 并且我想知道包的大小,然后再得到大包大小的应用程序。所以如果你使用 svelte-materialify,请告诉我构建包的大小。谢谢。

你可以在像 bundlephobia 这样的网站上回答这类问题。

对于 svelte-materialify :https://bundlephobia.com/result?p=svelte-materialify@0.3.4

81.5k, gzipped.

但是,这个库是 tree-shakable 的:你不使用的组件不会出现在最终的 js 中。你应该在你的项目中尝试,然后使用像 rollup-plugin-analyser 这样的插件来查看你的 context/pages.

中的最终大小

为了减小包的大小,我可以只使用需要的组件。但需要包装它最小包装。它在新版本 0.3.6 中具有包装器(屏幕显示文件大小 https://github.com/TheComputerM/svelte-materialify/issues/155)。

<script>
    import Button from 'svelte-materialify/src/components/Button/index.js';
    import MaterialAppMin from "svelte-materialify/src/components/MaterialApp/MaterialAppMin";
    let theme = 'light';
</script>

<MaterialAppMin {theme}>
<Button class="success-color">success</Button>
      ...
</MaterialAppMin>

它减小了包的大小。

但它会加载更多代码

import {Button} from 'svelte-materialify';

https://svelte-materialify.vercel.app/components/material-app/