mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
refactor: plugin templates (#1678)
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
parent
85f39858e5
commit
929a634013
@ -33,11 +33,11 @@ export const cssTemplate = {
|
||||
export const clientPluginTemplate = {
|
||||
filename: 'plugins/client.mjs',
|
||||
getContents (ctx: TemplateContext) {
|
||||
const { app } = ctx
|
||||
const clientPlugins = ctx.app.plugins.filter(p => !p.mode || p.mode !== 'server')
|
||||
return [
|
||||
importSources(app.plugins.filter(p => !p.mode || p.mode !== 'server').map(p => p.src)),
|
||||
importSources(clientPlugins.map(p => p.src)),
|
||||
'export default [',
|
||||
app.plugins.filter(p => !p.mode || p.mode !== 'server').map(p => importName(p.src)).join(',\n '),
|
||||
clientPlugins.map(p => importName(p.src)).join(',\n '),
|
||||
']'
|
||||
].join('\n')
|
||||
}
|
||||
@ -46,13 +46,13 @@ export const clientPluginTemplate = {
|
||||
export const serverPluginTemplate = {
|
||||
filename: 'plugins/server.mjs',
|
||||
getContents (ctx: TemplateContext) {
|
||||
const { app } = ctx
|
||||
const serverPlugins = ctx.app.plugins.filter(p => !p.mode || p.mode !== 'client')
|
||||
return [
|
||||
"import preload from '#app/plugins/preload.server'",
|
||||
importSources(app.plugins.filter(p => !p.mode || p.mode !== 'client').map(p => p.src)),
|
||||
importSources(serverPlugins.map(p => p.src)),
|
||||
'export default [',
|
||||
' preload,',
|
||||
app.plugins.filter(p => !p.mode || p.mode !== 'client').map(p => importName(p.src)).join(',\n '),
|
||||
serverPlugins.map(p => importName(p.src)).join(',\n '),
|
||||
']'
|
||||
].join('\n')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user