Skip to content
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

Add support for config named export From Configuration File #3246

Closed
zachleat opened this issue Apr 10, 2024 · 2 comments
Closed

Add support for config named export From Configuration File #3246

zachleat opened this issue Apr 10, 2024 · 2 comments
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file

Comments

@zachleat
Copy link
Member

zachleat commented Apr 10, 2024

Related to #1503 and #3244. Specifically the comment in #1503 (comment)

A more robust way to export config object via your configuration file. We’ll encourage folks to do this from now on instead of returning an object in your configuration callback (or even the set*Directory methods to programmatically set directories).

Setting directories data cascade (order of precedence):

  1. CLI --input (overrides input from any other methods)
  2. CLI --output (overrides output from any other methods)
  3. dir property in return object from configuration callback (backwards compatibility)
  4. set*Directory configuration API methods set*Directory Configuration API methods #1503
  5. config export from configuration file with a dir object inside (this is the new thing)

Examples

ESM

export default function(eleventyConfig) {
  eleventyConfig.directories.input; // has "./content/"
};

export const config = {
  dir: {
    input: "content"
  }
}

CommonJS

module.exports = function(eleventyConfig) {
  eleventyConfig.directories.input; // has "./content/"
};

module.exports.config = {
  dir: {
    input: "content"
  }
}

Update April 10: swapping this to be config instead of directories so that it works the same as the current return object. Switch your return to named config export instead.

@zachleat zachleat added this to the Eleventy 3.0.0 milestone Apr 10, 2024
@zachleat zachleat added the feature: 🛠 configuration Related to Eleventy’s Configuration file label Apr 10, 2024
@zachleat
Copy link
Member Author

Shipping with 3.0.0-alpha.6

@zachleat
Copy link
Member Author

@zachleat zachleat removed the needs-documentation Documentation for this issue/feature is pending! label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file
Projects
None yet
Development

No branches or pull requests

1 participant