diff --git a/vite.config.js b/vite.config.js index 3c972cd..50e4de2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,7 +4,7 @@ import { defineConfig } from 'vite'; import { name } from './package.json' function proRouterViews() { - + let views = {} return { name: 'pro-router-views', transformIndexHtml(html) { @@ -17,12 +17,15 @@ function proRouterViews() { if (/\.imba$/.test(id)) { let viewRegExp = /tag view-((\w|\S)+)( |\n)/g let result = null - let views = "" + let views_str = "" while(result = viewRegExp.exec(src)) { - if(result[1] != 'not_found') - views += "Views.push(\""+ result[1] +"\");" + let view = result[1] + if(view != 'not_found' && !views[view]){ + views[view] = true + views_str += "Views.push(\""+ result[1] +"\");" + } } - return { code: views+src, map: null } + return { code: views_str+src, map: null } } } }