You've already forked AstralRinth
forked from didirus/AstralRinth
Update docs examples + Add Select component + Add Card, Base, Title classes
This commit is contained in:
30
plugins/sveld.js
Normal file
30
plugins/sveld.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ComponentParser } from 'sveld'
|
||||
import sveltePreprocess from 'svelte-preprocess'
|
||||
import * as svelte from 'svelte/compiler'
|
||||
|
||||
export default function sveld() {
|
||||
return {
|
||||
name: 'vite-plugin-sveld',
|
||||
async transform(src, id) {
|
||||
if (id.endsWith('?raw&sveld')) {
|
||||
const raw = JSON.parse(src.split('export default ')[1])
|
||||
|
||||
let { code } = await svelte.preprocess(raw, sveltePreprocess({ postcss: true }), {
|
||||
filename: id
|
||||
})
|
||||
const data = new ComponentParser({
|
||||
verbose: false
|
||||
}).parseSvelteComponent(code, {
|
||||
filePath: id,
|
||||
moduleName: id
|
||||
})
|
||||
|
||||
|
||||
return {
|
||||
code: `export default ${JSON.stringify(data)}`,
|
||||
map: null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user