Skip to content

Commit aa496bc

Browse files
committed
fix($core): normalize theme path with Layout.vue correctly (close vuejs#2178)
1 parent 0ca620f commit aa496bc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: packages/@vuepress/core/lib/node/loadTheme.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@ module.exports = function loadTheme (ctx) {
6060
}
6161

6262
function normalizeThemePath (resolved) {
63-
const { entry, fromDep } = resolved
63+
const { entry, name, fromDep } = resolved
6464
if (fromDep) {
65+
const packageRoot = require.resolve(`${name}/package.json`)
66+
const { main } = require(packageRoot)
67+
if (main.endsWith('.vue')) {
68+
// For those cases that "main" field is set to .vue file
69+
// e.g. `layouts/Layout.vue`
70+
return parse(packageRoot).dir
71+
}
6572
return parse(require.resolve(entry)).dir
6673
} else if (entry.endsWith('.js') || entry.endsWith('.vue')) {
6774
return parse(entry).dir

0 commit comments

Comments
 (0)