This PR reworks asset handling in our vite plugin. Importing assets in js is now supported.
20 lines
484 B
TypeScript
20 lines
484 B
TypeScript
import type { PluginObj, types } from "@babel/core";
|
|
|
|
export function jsxComments(): PluginObj {
|
|
return {
|
|
name: "fresh-jsx-comment",
|
|
visitor: {
|
|
Program(path) {
|
|
const comments = (path.parent as types.File).comments;
|
|
if (comments) {
|
|
for (let i = 0; i < comments.length; i++) {
|
|
const comment = comments[i];
|
|
|
|
comment.value = comment.value.replaceAll(/@jsx\w+\s+[^\s*]+/g, "");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
};
|
|
}
|