提交 0a7e38ab 编写于 作者: U ULIVZ

fix($core): theme/styles/palette.styl doesn't work

BTW, remove Object usage of palette.
上级 0a142ef5
......@@ -26,7 +26,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
return console.error(logger.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'), false))
}
await fs.remove(outDir)
logger.debug('Dist directory: ' + chalk.gray(require('path').resolve(process.cwd(), outDir)))
logger.debug('Dist directory: ' + chalk.gray(path.resolve(process.cwd(), outDir)))
let clientConfig = createClientConfig(options, cliOptions).toConfig()
let serverConfig = createServerConfig(options, cliOptions).toConfig()
......
......@@ -24,23 +24,21 @@ module.exports = (options, ctx) => ({
// 2. write palette.styl
const { sourceDir, writeTemp } = ctx
const themePalette = ctx.themePalette
const { palette: userPalette } = ctx.siteConfig
const palettePath = path.resolve(sourceDir, '.vuepress/styles/palette.styl')
const themePalette = path.resolve(ctx.themePath, 'styles/palette.styl')
const userPalette = path.resolve(sourceDir, '.vuepress/styles/palette.styl')
const themePaletteContent = resolvePaletteContent(themePalette)
const userPaletteContent = resolvePaletteContent(userPalette)
const userPaletteContent2 = resolvePaletteContent(palettePath)
// user's palette can override theme's palette.
const paletteContent = themePaletteContent + userPaletteContent + userPaletteContent2
const paletteContent = themePaletteContent + userPaletteContent
await writeTemp('palette.styl', paletteContent)
}
})
/**
* resolve palette content
* @param {string|object} palette
* @param {string} palette
* @returns {string}
*/
......@@ -55,14 +53,8 @@ function resolvePaletteContent (palette) {
return ''
}
if (isString(palette)) {
if (fs.existsSync(palette)) {
return `@import(${JSON.stringify(palette)})\n`
}
return ''
} else if (isPlainObject(palette)) {
return Object.keys(palette).map(variableName => {
return `${variableName} = ${palette[variableName]}`
}).join('\n') + '\n'
if (isString(palette) && fs.existsSync(palette)) {
return `@import(${JSON.stringify(palette)})\n`
}
return ''
}
......@@ -69,8 +69,6 @@ module.exports = async function loadTheme (ctx) {
}
// handle theme api
const { palette: themePalette } = themeEntryFile
const layoutDirs = [
path.resolve(themePath, 'layouts'),
path.resolve(themePath, '.')
......@@ -135,7 +133,6 @@ module.exports = async function loadTheme (ctx) {
themePath,
layoutComponentMap,
themeEntryFile,
themePalette,
themeName,
themeShortcut
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册