pnpm add vite-plugin-generate-assets -D
// vite.config.js / vite.config.ts
import ViteGenerateAssets from 'vite-plugin-generate-assets';
export default {
plugins: [
ViteGenerateAssets()
]
}
interface IOptions {
/**
* Resource matching rules
* default: /\.(png|jpe?g|gif|webp|svg)$/i
*/
include?: RegExp;
/**
* Resource directory
* default: src/assets
*/
assetsDir?: string;
/**
* Output path
*default: src/assets/assets.ts
*/
outputFilePath?: string;
}
./src/assets
├── farm
│ ├── deworming.png
│ ├── harvest.png
├── [email protected]
├── item_selected.jpeg
├── pet
│ ├── icon-bg.jpg
const Assets = {
farm: {
Deworming: 'src/assets/farm/deworming.png',
Harvest: 'src/assets/farm/harvest.png',
},
FullGray2x: 'src/assets/[email protected]',
ItemSelected: 'src/assets/item_selected.jpeg',
pet: {
IconBg: 'src/assets/pet/icon-bg.jpg',
},
}
export default Assets;