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

allow merging of yaml, toml, js config #1374

wants to merge 1 commit into from

Conversation

neumayr
Copy link

@neumayr neumayr commented Feb 28, 2019

Summary

allows the merging of yaml, toml and js config

My Team manages eg. themeConfig.nav in config.yml for readability and ease of use. However some advanced js syntax can’t be managed by yaml like extendMarkdown: md => {md.use(…)}.
I would like to have two configuration files. config.yml and config.js work side by side.
One for simple theme config and the js for advanced configuration.

My Setup simplified

In the config.yml contains the config basic documentation authors can edit. The config.js contains advanced configuration for markdown and plugins a basic author better don't touch 😉

---
# .vuepress/config.yml
title: '📝 My Awesome Documentation'
description: "Awesome Docs"
port: 4000
// .vuepress/config.js
module.exports = {
  plugins: [
    ['@vuepress/search', { searchMaxSuggestions: 10 }],
    '@vuepress/last-updated'
  ],
  markdown: {
    lineNumbers: true,
    toc: {
      includeLevel: [2, 3, 4]
    },
    extendMarkdown: md => {
      md.use(require('markdown-it-mermaid').default)
    }
  }
}

🔗 #804

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated
  • Related tests have been updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

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.

/cc @ekoeryanto

* allows the merging `yaml`, `toml`, `js` config
* update documentation section

My Team manages eg. `themeConfig.nav` in `config.yml` for readability and ease of use. However some advanced js syntax can’t be managed by `yaml` like `extendMarkdown: md => {md.use(…)}`.
I would like to have two configuration files. `config.yml` and `config.js` work side by side.
One for simple theme config and the js for advanced configuration.

:link: #804
@ulivz ulivz self-assigned this Mar 2, 2019
Copy link
Member

@ulivz ulivz left a comment

Choose a reason for hiding this comment

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

This merge is unreasonable and will cause issues, because the config of vuepress allows users to export a function.

Thus, I think that you should do this merge in your config.js.

@@ -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.

@@ -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".

@ulivz ulivz closed this Mar 2, 2019
@neumayr
Copy link
Author

neumayr commented Mar 3, 2019

This merge is unreasonable and will cause issues, because the config of vuepress allows users to export a function.

Thank you, important information.
Is there an elegant way to check for a function and get this working?

Thus, I think that you should do this merge in your config.js.

Probably, but because other folks found this useful too I would try to get this working out of the box. @ulivz, you're a vuepress and js professional. Myself aren't. Share your knowledge ✌️

@neumayr neumayr deleted the multiple-config branch March 13, 2019 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants