@kaijudo/react-card-images
v0.1.1
Published
Image assets for Duel Master card creatures and spells.
Readme
@kaijudo/react-card-images
Image assets for Duel Master card creatures and spells.
Efficient Image Consumption
This package is optimized for tree-shaking - when you import a single image, only that image is downloaded/bundled, not all images in the package.
Usage
Method 1: Direct Path Import (Recommended - Best Tree-shaking)
Import images directly from the package path. This provides the best tree-shaking because bundlers can statically analyze which images are used.
// Import a single creature image
import mieleImage from "@kaijudo/react-card-images/creatures/miele-vizier-of-lightning.png";
// Import a single spell image
import brainSerum from "@kaijudo/react-card-images/spells/brain-serum.png";
// Use in component
<img src={mieleImage} alt="Miele Vizier" />;With Vite/Webpack: You can also use the ?url suffix to get the URL string:
import mieleImageUrl from "@kaijudo/react-card-images/creatures/miele-vizier-of-lightning.png?url";
// mieleImageUrl is a string URLMethod 2: Named Exports (Convenience)
Import from the main export. Only the imported images are bundled.
import { mieleVizierOfLightning } from "@kaijudo/react-card-images";
<img src={mieleVizierOfLightning} alt="Miele Vizier" />;Note: Method 1 (direct path import) provides better tree-shaking because bundlers can statically analyze the import path.
How It Works
- Images are NOT bundled into JavaScript - They remain as separate PNG files
- Package exports expose image directories -
./creatures/*and./spells/*are exposed viapackage.jsonexports - Bundler handles images at build time - Vite/Webpack processes images when they're imported
- Only imported images are included - Unused images are tree-shaken away
Available Images
Creatures
miele-vizier-of-lightning.pngastrocomet-dragon.pngboltail-dragon.pngdeadly-fighter-braid-claw.pngexplosive-fighter-ucarn.pngfatal-attacker-horvath.pngfonch-the-oracle.pnggigastand.pnggreatest-earth-planetary-dragon.pnggrim-soul-shadow-of-reversal.pngimmortal-baron-vorg.pnglarba-geer-the-immaculate.pngmarrow-ooze-the-twister.pngmetalwing-skyterror.pngpyrofighter-magnus.pngrimuel-cloudbreaker-elemental.pngripple-lotus-q.pngstardust-nex-elemental-dragon-knight.pngsupernova-pluto-deathbringer.pngtechno-totem.png
Spells
brain-serum.pngcrystal-memory.pngholy-awe.pnglaser-wing.pngmoonlight-flash.pngsolar-ray.pngsonic-wing.png
Adding New Images
Add image files to the appropriate directory:
src/creatures/for creature imagessrc/spells/for spell images
Optionally export them in
src/index.ts:export { default as newCreature } from "./creatures/new-creature.png";Images are automatically copied to
dist/during buildImport directly:
import newCreature from "@kaijudo/react-card-images/creatures/new-creature.png";
Tree-shaking Guarantee
✅ Only imported images are bundled - If you import 1 image, only 1 image is included in your bundle
✅ No JavaScript overhead - Images are separate files, not embedded in JS
✅ Works in workspace and published packages - Supports both workspace:* and npm registry imports
