mirror of
https://github.com/Moe-Sakura/frontend.git
synced 2026-05-10 00:44:13 +08:00
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:
@@ -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 配置
|
||||
|
||||
Reference in New Issue
Block a user