Skip to content

Instantly share code, notes, and snippets.

View EnixCoda's full-sized avatar
👀
Open for local/remote frontend opportunities

Enix EnixCoda

👀
Open for local/remote frontend opportunities
View GitHub Profile
@EnixCoda
EnixCoda / readme.md
Last active December 3, 2024 08:37
Override Vite's internal JSON plugin

In my special use case, I import JSON file and use them as functions.

For example,

import validator from './example.schema.json'; // schema JSON imported as function
import data from './data.json';                // general JSON imported as data

console.log(data); // { value: 'random-data' }
validator(data);
@EnixCoda
EnixCoda / readme.md
Last active December 3, 2024 09:01
Vite custom JSON loader plugin

In my special use case, I import JSON file and use them as functions.

For example,

import validator from './example.schema.json'; // schema JSON imported as function
import data from './data.json';                // general JSON imported as data

console.log(data); // { value: 'random-data' }
validator(data);