From 2408b48a03b29813c2f07ce883c58aa9d5ffb7c4 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Sun, 15 Jan 2023 19:37:50 +0100 Subject: [PATCH] refuse duplicates --- vite.config.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 } } } }