Skip to content

Commit

Permalink
fix($core): normalize theme path with Layout.vue correctly (close vue…
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Feb 17, 2020
1 parent 0ca620f commit aa496bc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@vuepress/core/lib/node/loadTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ module.exports = function loadTheme (ctx) {
}

function normalizeThemePath (resolved) {
const { entry, fromDep } = 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 .vue file
// e.g. `layouts/Layout.vue`
return parse(packageRoot).dir
}
return parse(require.resolve(entry)).dir
} else if (entry.endsWith('.js') || entry.endsWith('.vue')) {
return parse(entry).dir
Expand Down

0 comments on commit aa496bc

Please sign in to comment.