vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.43k stars 4.79k forks source link

Support for `config.cjs` and/or ES6 module #2466

Open akauppi opened 4 years ago

akauppi commented 4 years ago

Feature request

Ability to name the configuration file config.cjs (for CommonJS), and/or express configuration as an ES6 module.

What problem does this feature solve?

Currently (VuePress 1.5.2) it seems the configuration file must be config.js and that file must be given with CommonJS export syntax.

The world is in between two module eras, and projects start using ES6 modules. There is a convention about doing this in Node, defining "type": "module" in package.json (to default .js to ES6 module loading) and a recommendation of naming files explicitly to .cjs for CommonJS and .mjs for ES6.

VuePress is not acting according to such convention.

What does the proposed API look like?

One would be able to get configuration via either config.cjs, config.mjs or the default interpretation of config.js. At the least, I would like config.cjs to be found.

How should this be implemented in your opinion?

Unfortunately, I don't have insight about this.

Are you willing to work on this yourself?

I can help test a PR.

soletan commented 2 years ago

Created PR in #2933 ... as a quick fix, you can use config.yml or config.toml when feasible.