mirror of
https://github.com/bartvdbraak/hellob.art.git
synced 2025-06-28 07:19:09 +00:00
fix: make sure vite is doing its thing
This commit is contained in:
parent
ea491c3148
commit
791d2cae8f
3 changed files with 20 additions and 7 deletions
|
@ -4,7 +4,7 @@ import { defineConfig } from 'vite';
|
|||
import fs from 'fs';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [base64(['.jpg']), enhancedImages(), rawFonts(['.woff']), sveltekit()],
|
||||
plugins: [base64(), enhancedImages(), rawFonts(['.woff']), sveltekit()],
|
||||
define: {
|
||||
'import.meta.env.VERCEL_URL': JSON.stringify(process.env.VERCEL_URL)
|
||||
}
|
||||
|
@ -22,15 +22,25 @@ function rawFonts(ext: string[]) {
|
|||
};
|
||||
}
|
||||
|
||||
function base64(ext: string[]) {
|
||||
function base64() {
|
||||
return {
|
||||
name: 'vite-plugin-base64-loader',
|
||||
// transform(_code: string, id: string) {
|
||||
// const [path, query] = id.split('?');
|
||||
// if (query === 'base64' && ext.some((e) => id.endsWith(e))) {
|
||||
// const base64 = fs.readFileSync(path, { encoding: 'base64' });
|
||||
// return { code: `export default ${JSON.stringify(base64)}`, map: null };
|
||||
// }
|
||||
// }
|
||||
transform(_code: string, id: string) {
|
||||
const [path, query] = id.split('?');
|
||||
if (query === 'base64' && ext.some((e) => id.endsWith(e))) {
|
||||
const base64 = fs.readFileSync(path, { encoding: 'base64' });
|
||||
return { code: `export default ${JSON.stringify(base64)}`, map: null };
|
||||
|
||||
if (query !== 'base64') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const base64 = fs.readFileSync(path, { encoding: 'base64' });
|
||||
return { code: `export default ${JSON.stringify(base64)}`, map: null };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue