import { imba } from 'vite-plugin-imba'; import { resolve } from 'path' import { defineConfig } from 'vite'; import { name } from './package.json' function proRouterViews() { return { name: 'pro-router-views', transformIndexHtml(html) { return html.replace('
', '') }, transform: { order: 'pre', handler(src, id) { if (/\.imba$/.test(id)) { let viewRegExp = /tag view-((\w|\S)+)( |\n)/g let result = null let views = "" while(result = viewRegExp.exec(src)) { views += "Views.push(\""+ result[1] +"\");" } return { code: views+src, map: null } } } } } } export default defineConfig({ plugins: [proRouterViews(), imba()], build: { lib: { name: name, fileName: "index", entry: resolve(__dirname, 'src/main.imba'), }, }, });