mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-04-19 20:59:00 +00:00
feat: new chord editor prototype
This commit is contained in:
19
vite-plugin-lezer.ts
Normal file
19
vite-plugin-lezer.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { buildParserFile } from "@lezer/generator";
|
||||
import type { Plugin, Rollup } from "vite";
|
||||
|
||||
const fileRegex = /\.(grammar)$/;
|
||||
|
||||
export function lezerGrammarPlugin() {
|
||||
return {
|
||||
name: "lezer-grammar",
|
||||
transform(code, id) {
|
||||
if (fileRegex.test(id)) {
|
||||
return {
|
||||
code: buildParserFile(code).parser,
|
||||
map: null,
|
||||
} satisfies Rollup.TransformResult;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
} satisfies Plugin;
|
||||
}
|
||||
Reference in New Issue
Block a user