You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi All! I have project(called A) built with remix/vite, and it include my other library(called B) built based on storybook and vite. Both A and B have installed @tabler/icons-react as dev dependency.
When I build library B itself, the tabler icons are doing okay, only include icons been imported in the build. But when I build the project A, all of the tabler icons in B are all transforming and packed into build/client/assets/B.js. It occupied a huge bundle size. I'm not sure if this is related to treeshaking or some configs? Hope someone can help me on this! Thanks in advance.
Project A vite config:
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import mdx from "@mdx-js/rollup";
import remarkFrontmatter from "remark-frontmatter";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import { visualizer } from "rollup-plugin-visualizer";
export default defineConfig({
ssr: {
noExternal: ["pdfmake/build/vfs_fonts" /* , "dc" */],
},
plugins: [
mdx({
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter],
}),
remix(),
tsconfigPaths(),
visualizer({
open: true,
gzipSize: true,
template: "treemap",
}),
],
});
I also had this issue where building my app would include all the icons.
The workaround is to import all icons as a default export. I'm using Svelte but it should be similar enough.
For example : import IconUser from "@tabler/icons-svelte/IconUser.svelte"
The annoying part is that each import only adds a single icon, so you have to do it multiple times if you use a lot of icons.
I've had this issue since 3.0.0 and I haven't seen anything changed yet. I really like the library so I won't change it, but it would be convenient to import the icons as named imports, like import { IconUser } from "@tabler/icons-svelte".
I also had this issue where building my app would include all the icons. The workaround is to import all icons as a default export. I'm using Svelte but it should be similar enough. For example : import IconUser from "@tabler/icons-svelte/IconUser.svelte"
The annoying part is that each import only adds a single icon, so you have to do it multiple times if you use a lot of icons. I've had this issue since 3.0.0 and I haven't seen anything changed yet. I really like the library so I won't change it, but it would be convenient to import the icons as named imports, like import { IconUser } from "@tabler/icons-svelte".
Thank you. I will try your approach to import icons directly
Browser
chrome
OS
windows 10
Screen size
1920x1080
Describe the bug
Hi All! I have project(called A) built with remix/vite, and it include my other library(called B) built based on storybook and vite. Both A and B have installed @tabler/icons-react as dev dependency.
When I build library B itself, the tabler icons are doing okay, only include icons been imported in the build. But when I build the project A, all of the tabler icons in B are all transforming and packed into build/client/assets/B.js. It occupied a huge bundle size. I'm not sure if this is related to treeshaking or some configs? Hope someone can help me on this! Thanks in advance.
Project A vite config:
Library B vite config:
How to reproduce
Screenshots
No response
JSFiddle
No response
The text was updated successfully, but these errors were encountered: