perf: tree-shake dependencies from server (#1647)
This commit is contained in:
parent
357dff2140
commit
6dc38c7d8e
12 changed files with 90 additions and 19 deletions
|
@ -128,10 +128,10 @@ export default defineNuxtConfig({
|
|||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
transpile: ['masto'],
|
||||
},
|
||||
nitro: {
|
||||
alias: {
|
||||
'isomorphic-ws': 'unenv/runtime/mock/proxy',
|
||||
},
|
||||
esbuild: {
|
||||
options: {
|
||||
target: 'esnext',
|
||||
|
@ -143,12 +143,37 @@ export default defineNuxtConfig({
|
|||
ignore: ['/settings'],
|
||||
},
|
||||
},
|
||||
sourcemap: !isDevelopment,
|
||||
hooks: {
|
||||
'nitro:config': function (config) {
|
||||
const nuxt = useNuxt()
|
||||
config.virtual = config.virtual || {}
|
||||
config.virtual['#storage-config'] = `export const driver = ${JSON.stringify(nuxt.options.appConfig.storage.driver)}`
|
||||
},
|
||||
'vite:extendConfig': function (config, { isServer }) {
|
||||
if (isServer) {
|
||||
const alias = config.resolve!.alias as Record<string, string>
|
||||
for (const dep of ['eventemitter3', 'isomorphic-ws'])
|
||||
alias[dep] = resolve('./mocks/class')
|
||||
for (const dep of ['shiki-es', 'fuse.js'])
|
||||
alias[dep] = 'unenv/runtime/mock/proxy'
|
||||
const resolver = createResolver(import.meta.url)
|
||||
|
||||
config.plugins!.unshift({
|
||||
name: 'mock',
|
||||
enforce: 'pre',
|
||||
resolveId(id) {
|
||||
if (id.match(/(^|\/)(@tiptap)\//))
|
||||
return resolver.resolve('./mocks/tiptap.ts')
|
||||
if (id.match(/(^|\/)(prosemirror)/))
|
||||
return resolver.resolve('./mocks/prosemirror.ts')
|
||||
},
|
||||
})
|
||||
|
||||
const noExternal = config.ssr!.noExternal as string[]
|
||||
noExternal.push('masto', '@fnando/sparkline', 'vue-i18n', '@mastojs/ponyfills')
|
||||
}
|
||||
},
|
||||
},
|
||||
app: {
|
||||
keepalive: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue