mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 03:23:02 +00:00
refactor: batch 3
This commit is contained in:
15
support/b64-loader.ts
Normal file
15
support/b64-loader.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { Plugin } from 'vite';
|
||||
|
||||
export const base64Loader: Plugin = {
|
||||
name: 'base64-loader',
|
||||
async transform(_: unknown, id: string) {
|
||||
const [path, query] = id.split('?');
|
||||
if (query != 'base64') return null;
|
||||
|
||||
const data = await readFile(path);
|
||||
const base64 = data.toString('base64');
|
||||
|
||||
return `export default '${base64}';`;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user