提交 6db5e83a 编写于 作者: E Evan You

allow customizing accentColor

上级 41640a2b
......@@ -10,6 +10,8 @@ next: ./getting-started
### PWA Support
### Dropdown Items in Navbar
### Algolia DocSearch Integration
## Why Not ...?
......
......@@ -13,7 +13,7 @@ if (module.hot) {
if (siteData.base !== prevBase) {
window.alert(
`[vuepress] Site base has changed. ` +
`Please restart dev server to ensure correct paths.`
`Please restart dev server to ensure correct asset paths.`
)
}
})
......
// colors
@import '../../app/.temp/accent.stylus' // generated from user config
$textColor = #2c3e50
$accentColor = darken(#41b883, 5%)
$borderColor = #eaecef
$codeBgColor = #282c34
......
......@@ -44,6 +44,12 @@ if (!Object.assign) Object.assign = require('object-assign')`
}
writeTemp('polyfill.js', polyfillCode)
// 5. handle user accentColor
if (options.useDefaultTheme) {
const accentColor = options.siteData.themeConfig.accentColor || '#3eaf7c'
writeTemp('accent.stylus', `$accentColor = ${accentColor}`)
}
return options
}
......@@ -79,6 +85,12 @@ async function resolveOptions (sourceDir) {
})
}
// resolve theme
const useDefaultTheme = (
!siteConfig.theme &&
!fs.existsSync(path.resolve(vuepressDir, 'theme'))
)
const options = {
siteConfig,
sourceDir,
......@@ -89,16 +101,11 @@ async function resolveOptions (sourceDir) {
pageFiles: sort(await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })),
pagesData: null,
themePath: null,
notFoundPath: null
notFoundPath: null,
useDefaultTheme
}
// resolve theme
const hasTheme = (
siteConfig.theme ||
fs.existsSync(path.resolve(vuepressDir, 'theme'))
)
if (!hasTheme) {
if (useDefaultTheme) {
// use default theme
options.themePath = path.resolve(__dirname, 'default-theme/Layout.vue')
options.notFoundPath = path.resolve(__dirname, 'default-theme/NotFound.vue')
......
......@@ -159,7 +159,8 @@ module.exports = function createBaseConfig ({
})
rule.use('postcss-loader').loader('postcss-loader').options(Object.assign({
plugins: [require('autoprefixer')]
plugins: [require('autoprefixer')],
sourceMap: !isProd
}, siteConfig.postcss))
if (loader) {
......@@ -172,7 +173,9 @@ module.exports = function createBaseConfig ({
createCSSRule('scss', /\.scss$/, 'sass-loader')
createCSSRule('sass', /\.sass$/, 'sass-loader', { indentedSyntax: true })
createCSSRule('less', /\.less$/, 'less-loader')
createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader')
createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader', {
preferPathResolver: 'webpack'
})
config
.plugin('vue-loader')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册