xiaohongshu
xiaohongshu
dev-assets-vite-asset-loading
Vite 6 asset loading patterns that avoid '?import' query parameter pollution. Use when working with static assets (FBX models, images, fonts), dealing with Vite 6's new asset handling, or loading assets from public vs src/assets directories.
Full skill instructions
import { useFBX } from '@react-three/drei';
// CORRECT - Uses public directory with absolute path
function CharacterModel({ characterType }: { characterType: string }) {
const fbx = useFBX(`/assets/${characterType}.fbx`);
return <primitive object={fbx} />;
}
// For public assets that need URL
const imageUrl = new URL('/assets/images/splash.png', import.meta.url);
// For assets that need processing
import backgroundImage from '@/assets/images/background.jpg';
// For CSS imports
import '@/styles/global.css';
❌ DON'T: Use import statements for public directory assets
import characterModel from '/assets/character.fbx'; // Creates '?import' query
✅ DO: Use absolute paths for public assets
// In JSX
<img src="/assets/logo.png" alt="Logo" />
// Or with URL constructor
const assetUrl = new URL('/assets/data.json', import.meta.url);
❌ DON'T: Mix public and src/assets references arbitrarily
// Bad - inconsistent approach
function MixedAsset() {
// This should be in public/ with absolute path
const localAsset = require('@/assets/icon.png');
// This should be imported properly
const publicAsset = '/assets/icon.png';
}
✅ DO: Consistent directory strategy
// All public assets use absolute paths
function ConsistentAssets() {
return (
<div>
<img src="/assets/public-image.jpg" alt="Public" />
<Model assetUrl="/assets/model.fbx" />
</div>
);
}
public/)Use for:
Reference pattern:
// Always use absolute paths starting with /
const assetPath = '/assets/Blaster Kit/Models/FBX format/rifle.fbx';
const fbx = useFBX(assetPath);
src/assets/)Use for:
Import pattern:
import processedImage from '@/assets/images/hero.png';
import styles from '@/styles/component.module.css';
// vite.config.js
export default defineConfig({
base: '/your-app-path/', // Important for public assets
assetsInclude: ['**/*.fbx', '**/*.glb'],
// ... other config
});
// For cache busting on public assets
const versionedAsset = `/assets/image.jpg?v=${APP_VERSION}`;
// Or for dynamic assets
const dynamicAsset = new URL(`/assets/${assetId}.png?theme=${theme}`, import.meta.url);
// Absolute paths work in dev
const devAsset = '/assets/development-only.json';
// Ensure base path is correct for production deployment
const prodAsset = `${import.meta.env.BASE_URL}assets/production.json`;
import { useFBX, useProgress } from '@react-three/drei';
import { Suspense } from 'react';
function SequentialLoader({ characters }: { characters: string[] }) {
return (
<Suspense fallback={<LoadingScreen />}>
{characters.map((char, index) => (
<CharacterModel key={index} characterType={char} />
))}
</Suspense>
);
}
function CharacterModel({ characterType }: { characterType: string }) {
const fbx = useFBX(`/assets/${characterType}.fbx`);
// Process and return the model
return (
<primitive
object={fbx}
position={[0, 0, 0]}
scale={[1, 1, 1]}
/>
);
}
function AssetLoader() {
const { active, progress, errors, item } = useProgress();
if (errors.length > 0) {
return <div>Error loading assets</div>;
}
return (
<div>
{active && <div>Loading: {item} - {progress.toFixed(0)}%</div>}
</div>
);
}
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience