Skip to content

Commit

Permalink
fix($core): theme/styles/index.styl doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Oct 7, 2018
1 parent f098013 commit 1995273
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/@vuepress/core/lib/internal-plugins/style/index.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
}
})

0 comments on commit 1995273

Please sign in to comment.