Skip to content

allow merging of yaml, toml, js config #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = {
title: 'Hello VuePress',
description: '# Hello, VuePress!',
dest: 'vuepress',
base: 'vuepress',
head: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: Hello VuePress
description: '# Hello, VuePress!'
12 changes: 7 additions & 5 deletions packages/@vuepress/core/lib/prepare/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ module.exports = function loadConfig (vuepressDir, bustCache = true) {
// resolve siteConfig
let siteConfig = {}
if (fs.existsSync(configYmlPath)) {
siteConfig = parseConfig(configYmlPath)
} else if (fs.existsSync(configTomlPath)) {
siteConfig = parseConfig(configTomlPath)
} else if (fs.existsSync(configPath)) {
siteConfig = require(configPath)
siteConfig = Object.assign(siteConfig, parseConfig(configYmlPath))
}
if (fs.existsSync(configTomlPath)) {
siteConfig = Object.assign(siteConfig, parseConfig(configTomlPath))
}
if (fs.existsSync(configPath)) {
siteConfig = Object.assign(siteConfig, require(configPath))
}

return siteConfig
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const container = require('markdown-it-container')

module.exports = ctx => ({
module.exports = {
dest: '../../vuepress',
locales: {
'/': {
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = ctx => ({
}
},
plugins: [
['@vuepress/i18n-ui', !ctx.isProd],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've tested several scenarios and looked at the netlify build and output. I did't wanted to change the vuepress config. I've awaited some constructive feedback, this is why I've asked this in the description.

Other information:
From reading the docs I assume module.export is an object. Is this fact correct? If not, I would need help on how to elegant require an object or function.

['@vuepress/i18n-ui'],
['@vuepress/back-to-top', true],
['@vuepress/pwa', {
serviceWorker: true,
Expand All @@ -82,7 +82,7 @@ module.exports = ctx => ({
: '</UpgradePath>'
})
},
})
}

function getGuideSidebar (groupA, groupB) {
return [
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/docs/guide/basic-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you've got the dev server running, you should see the page now has a header w
Consult the [Config Reference](../config/README.md) for a full list of options.

::: tip Alternative Config Formats
You can also use YAML (`.vuepress/config.yml`) or TOML (`.vuepress/config.toml`) formats for the configuration file.
You can also split config and use YAML (`.vuepress/config.yml`) or TOML (`.vuepress/config.toml`) formats for the configuration. All configuration files will be merged together.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you should emphasize that this is only "Shadow Merge".

:::

## Theme Configuration
Expand Down