feat: add global fix for PrismJS in Vite configuration

- Introduced a new plugin to ensure PrismJS is correctly referenced in components, preventing issues with global scope.
- The plugin modifies the code for PrismJS components to use the appropriate global context, enhancing compatibility.
This commit is contained in:
AdingApkgg
2026-03-30 23:59:32 +08:00
parent 5cb5062c7a
commit 048560fd0a

View File

@@ -19,6 +19,17 @@ export default defineConfig({
},
plugins: [
{
name: 'prismjs-global-fix',
transform(code, id) {
if (id.includes('prismjs/components/') && !id.includes('prism-core')) {
return {
code: `var Prism = (typeof window !== 'undefined' ? window : globalThis).Prism;\n${code}`,
map: null,
}
}
},
},
vue(),
tailwindcss(),
// PWA 配置