提交 a63f3aed 编写于 作者: U ULIVZ

fix: enhance app doesn't work due to interface change

上级 b20c23bd
...@@ -8,7 +8,7 @@ import dataMixin from './dataMixin' ...@@ -8,7 +8,7 @@ import dataMixin from './dataMixin'
import store from './store' import store from './store'
import { routes } from '@temp/routes' import { routes } from '@temp/routes'
import { siteData } from '@temp/siteData' import { siteData } from '@temp/siteData'
import appEnhancers from '@temp/appEnhancers.js' import appEnhancers from '@temp/app-enhancers.js'
// suggest dev server restart on base change // suggest dev server restart on base change
if (module.hot) { if (module.hot) {
......
...@@ -11,7 +11,7 @@ module.exports = class Tapable { ...@@ -11,7 +11,7 @@ module.exports = class Tapable {
*/ */
tap (name, value) { tap (name, value) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
this.items.push(value.map(i => ({ value: i, name }))) return this.items.push(...value.map(i => ({ value: i, name })))
} }
this.items.push({ value, name }) this.items.push({ value, name })
} }
......
...@@ -6,34 +6,36 @@ const { pathsToModuleCode } = require('../../prepare/codegen') ...@@ -6,34 +6,36 @@ const { pathsToModuleCode } = require('../../prepare/codegen')
const logger = require('../../util/logger') const logger = require('../../util/logger')
module.exports = class EnhanceAppFilesOption extends Tapable { module.exports = class EnhanceAppFilesOption extends Tapable {
add (value, pluginName) { tap (pluginName, value) {
if (typeof value === 'function') { if (typeof value === 'function') {
value = value() value = value()
} }
super.add(value, pluginName) super.tap(pluginName, value)
} }
async run (...args) { async run (...args) {
const manifest = [] const manifest = []
console.log(this.items)
// 1. write enhance app files. // 1. write enhance app files.
for (const [index, value] of this.items.entries()) { for (const [index, value] of this.items.entries()) {
const { filepath, pluginName } = value const { value: filepath, name: pluginName } = value
if (fs.existsSync(filepath)) { if (fs.existsSync(filepath)) {
const destPath = await writeTemp( const destPath = await writeTemp(
`enhance-app-files/${index}.js`, `app-enhancers/enhancer-${index}.js`,
`export { default } from ${JSON.stringify(filepath)}` `export { default } from ${JSON.stringify(filepath)}`
) )
manifest.push(destPath) manifest.push(destPath)
} else { } else {
logger.debug( logger.debug(
chalk.gray(`[vuepress-plugin-${pluginName}]`) + chalk.gray(`[vuepress-plugin-${pluginName}] `) +
`${chalk.cyan(filepath)} Not Found.` `${chalk.cyan(filepath)} Not Found.`
) )
} }
} }
// 2. write entry file. // 2. write entry file.
await writeTemp('appEnhancers.js', pathsToModuleCode(manifest)) await writeTemp('app-enhancers.js', pathsToModuleCode(manifest))
} }
} }
export default function (Vue) { export default function ({ Vue }) {
Vue.use(/**/) console.warn('[vuepress-plugin-test] enhancing !!!')
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册