提交 057d8bf3 编写于 作者: O ocavue 提交者: ULIVZ

fix($core): failed to load theme when using "layouts/Layout.vue" as entry file...

fix($core): failed to load theme when using "layouts/Layout.vue" as entry file (close: #1563) (#1564)
上级 15784acc
module.exports = {}
// This file is just for jest.
{
"name": "vuepress-theme-without-index",
"main": "Layout.vue"
}
......@@ -18,6 +18,7 @@ describe('App', () => {
theme: '@vuepress/default',
emp: docsTempPath
})
await app.process()
expect(app.sourceDir).toBe(docsPath)
}))
})
......
module.exports = {
title: 'Hello VuePress',
description: '# Hello, VuePress!',
theme: 'vuepress-theme-without-index'
}
......@@ -56,17 +56,7 @@ module.exports = function loadTheme (ctx) {
function normalizeThemePath (resolved) {
const { entry, name, fromDep } = resolved
if (fromDep) {
const packageRoot = require.resolve(`${name}/package.json`)
const { main } = require(packageRoot)
if (main.endsWith('.vue')) {
// For those cases that "main" field is set to an non-index file
// e.g. `layouts/Layout.vue`
return packageRoot
} else {
// For those cases that "index.js" is not at package root
// e.g. `lib/index.js` (#1362)
return parse(require.resolve(name)).dir
}
return parse(require.resolve(name)).dir
} else if (entry.endsWith('.js') || entry.endsWith('.vue')) {
return parse(entry).dir
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册