diff --git a/lib/app/app.js b/lib/app/app.js index c2fa6728ec..ad7fb7675d 100644 --- a/lib/app/app.js +++ b/lib/app/app.js @@ -6,6 +6,7 @@ import dataMixin from './dataMixin' import NotFound from '@notFound' import { routes } from '@temp/routes' import { siteData } from '@temp/siteData' +import enhanceApp from '@temp/enhanceApp' // suggest dev server restart on base change if (module.hot) { @@ -64,14 +65,20 @@ export function createApp () { } }) - const app = new Vue({ - router, - render (h) { - return h('div', { attrs: { id: 'app' }}, [ - h('router-view', { ref: 'layout' }) - ]) - } - }) + const options = {} + + enhanceApp({ Vue, options, router }) + + const app = new Vue( + Object.assign(options, { + router, + render (h) { + return h('div', { attrs: { id: 'app' }}, [ + h('router-view', { ref: 'layout' }) + ]) + } + }) + ) return { app, router } } diff --git a/lib/prepare.js b/lib/prepare.js index 00c65973fe..a62dc0732f 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -50,6 +50,16 @@ if (!Object.assign) Object.assign = require('object-assign')` await writeTemp(`override.styl`, hasUserOverride ? `@import(${JSON.stringify(overridePath)})` : ``) } + // 6. handle enhanceApp.js + const enhancePath = path.resolve(sourceDir, '.vuepress/enhanceApp.js') + const hasEnhancePath = fs.existsSync(enhancePath) + await writeTemp( + 'enhanceApp.js', + hasEnhancePath + ? `export { default } from ${JSON.stringify(enhancePath)}` + : `export default function () {}` + ) + return options }