diff --git a/packages/@vuepress/core/lib/prepare/loadTheme.js b/packages/@vuepress/core/lib/prepare/loadTheme.js index c06820f18a..9cbbe2e118 100644 --- a/packages/@vuepress/core/lib/prepare/loadTheme.js +++ b/packages/@vuepress/core/lib/prepare/loadTheme.js @@ -33,9 +33,13 @@ module.exports = async function loadTheme (ctx) { const theme = siteConfig.theme || cliOptions.theme const themeResolver = getThemeResolver() + const absoluteThemePath = path.resolve(theme) + const useAbsolutePath = + fs.existsSync(absoluteThemePath) && + (fs.readdirSync(absoluteThemePath)).length > 0 + const localThemePath = path.resolve(vuepressDir, 'theme') const useLocalTheme = - !fs.existsSync(theme) && fs.existsSync(localThemePath) && (fs.readdirSync(localThemePath)).length > 0 @@ -44,7 +48,10 @@ module.exports = async function loadTheme (ctx) { let themeName let themeShortcut - if (useLocalTheme) { + if (useAbsolutePath) { + themePath = absoluteThemePath + logger.tip(`\nApply theme located at ${chalk.gray(themePath)}...`) + } else if (useLocalTheme) { themePath = localThemePath logger.tip(`\nApply theme located at ${chalk.gray(themePath)}...`) } else if (isString(theme)) {