vite-plugin-meta-tags
Version:
A Vite plug-in to automatically inject meta tags into your index.html
20 lines (19 loc) • 604 B
JavaScript
import { tagsGenerator } from './generator.js';
export function meta(meta, injectTo = 'head-prepend', custom) {
return {
name: 'vite:meta-tags',
transformIndexHtml: {
order: 'post',
handler: function () {
const tags = Array.from(tagsGenerator(meta, injectTo));
if (!custom) {
return tags;
}
if (typeof custom === 'function') {
return [...custom(), ...tags];
}
return [...custom, ...tags];
},
},
};
}