mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-11 13:02:22 +08:00
perf(build): filter SVGR loads before the JavaScript bridge
This commit is contained in:
+10
-1
@@ -5,11 +5,20 @@ import react from '@vitejs/plugin-react'
|
||||
import { defineConfig } from 'vite'
|
||||
import svgr from 'vite-plugin-svgr'
|
||||
|
||||
const svgPlugin = svgr()
|
||||
const svgLoad = svgPlugin.load
|
||||
if (!svgLoad) throw new Error('vite-plugin-svgr must provide a load hook')
|
||||
// SVGR's internal include filter still crosses the JS bridge for every module.
|
||||
svgPlugin.load = {
|
||||
filter: { id: /\.svg\?react$/ },
|
||||
handler: typeof svgLoad === 'function' ? svgLoad : svgLoad.handler,
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
root: 'src',
|
||||
server: { port: 3000 },
|
||||
plugins: [
|
||||
svgr(),
|
||||
svgPlugin,
|
||||
react(),
|
||||
legacy({
|
||||
modernTargets: ['edge>=109', 'safari>=14'],
|
||||
|
||||
Reference in New Issue
Block a user