File tree 1 file changed +10
-7
lines changed
packages/@vuepress/core/lib/prepare
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,17 @@ module.exports = function loadTheme (ctx) {
54
54
function normalizeThemePath ( resolved ) {
55
55
const { entry, name, fromDep } = resolved
56
56
if ( fromDep ) {
57
- const pkgPath = require . resolve ( name )
58
- let packageRootDir = parse ( pkgPath ) . dir
59
- // For those cases that "main" field was set to non-index file
60
- // e.g. `layouts/Layout.vue`
61
- while ( ! fs . existsSync ( `${ packageRootDir } /package.json` ) ) {
62
- packageRootDir = resolve ( packageRootDir , '..' )
57
+ const packageRoot = require . resolve ( `${ name } /package.json` )
58
+ const { main } = require ( packageRoot )
59
+ if ( main . endsWith ( '.vue' ) ) {
60
+ // For those cases that "main" field is set to an non-index file
61
+ // e.g. `layouts/Layout.vue`
62
+ return packageRoot
63
+ } else {
64
+ // For those cases that "index.js" is not at package root
65
+ // e.g. `lib/index.js` (#1362)
66
+ return parse ( require . resolve ( name ) ) . dir
63
67
}
64
- return packageRootDir
65
68
} else if ( entry . endsWith ( '.js' ) || entry . endsWith ( '.vue' ) ) {
66
69
return parse ( entry ) . dir
67
70
} else {
You can’t perform that action at this time.
0 commit comments