You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
972 B

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