diff --git a/packages/@vuepress/core/lib/internal-plugins/style/index.js b/packages/@vuepress/core/lib/internal-plugins/style/index.js index b28329e908..04fb10b773 100644 --- a/packages/@vuepress/core/lib/internal-plugins/style/index.js +++ b/packages/@vuepress/core/lib/internal-plugins/style/index.js @@ -1,12 +1,12 @@ const { fs, path, logger, chalk } = require('@vuepress/shared-utils') -module.exports = (options, context) => ({ +module.exports = (options, ctx) => ({ name: '@vuepress/internal-style', enhanceAppFiles: [path.resolve(__dirname, 'client.js')], async ready () { - const { sourceDir, writeTemp } = context + const { sourceDir, writeTemp } = ctx const overridePath = path.resolve(sourceDir, '.vuepress/override.styl') const hasUserOverride = fs.existsSync(overridePath) @@ -15,10 +15,17 @@ module.exports = (options, context) => ({ logger.tip(`${chalk.magenta('override.styl')} has been deprecated from v1.0.0, using ${chalk.cyan('.vuepress/style/palette.styl')} instead.\n`) } - // style.styl API. - const stylePath = path.resolve(sourceDir, '.vuepress/styles/index.styl') - const hasUserStyle = fs.existsSync(stylePath) - await writeTemp('style.styl', hasUserStyle ? `@import(${JSON.stringify(stylePath)})` : '') + const themeStyle = path.resolve(ctx.themePath, 'styles/index.styl') + const userStyle = path.resolve(sourceDir, '.vuepress/styles/index.styl') + + const themeStyleContent = fs.existsSync(themeStyle) + ? `@import(${JSON.stringify(themeStyle)})` + : '' + const userStyleContent = fs.existsSync(userStyle) + ? `@import(${JSON.stringify(userStyle)})` + : '' + + const styleContent = themeStyleContent + userStyleContent + await writeTemp('style.styl', styleContent) } }) -