- Stable
2.0.1
- Beta
3.0.0-beta.1
- Canary
3.0.0-alpha.19
Toggle Menu
Eleventy
1.93s
Gatsby
29.05s
Quick Tip: Use local plugins to reduce config file size
Is your .eleventy.js
file getting too large? You can create your own plugin to move some code out.
First, create a plugin file. We recommend creating a config
or _config
folder in your project to store config files in. Make sure that folder isn’t getting copied out to your built site. Then create a file in that folder. It doesn’t matter what you name it.
Filename config/local-plugin.js
module.exports = function (eleventyConfig) {
// Move any code you want from `.eleventy.js` to here
};
WARNING:
Any variables defined in your
.eleventy.js
file will not be available to your plugin. Consider moving those variables into your plugin file, or passing them in as options.Next, use the eleventyConfig.addPlugin()
method to add your plugin.
Filename .eleventy.js
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(require("./config/local-plugin.js"));
};
All Quick Tips
- Quick Tip: Inline Minified CSS
- Quick Tip: Add Edit on GitHub Links to All Pages
- Quick Tip: Inline Minified JavaScript
- Quick Tip: Zero Maintenance Tag Pages for your Blog
- Quick Tip: Super Simple CSS Concatenation
- Quick Tip: Adding a 404 Not Found Page to your Static Site
- Quick Tip: Fetch GitHub Stargazers Count (and More) at Build Time
- Quick Tip: Trigger a Netlify Build Every Day
- Quick Tip: Cache Data Requests
- Quick Tip: Transform Global Data using an `eleventyComputed.js` Global Data File
- Quick Tip: Use local plugins to reduce config file size
- Quick Tip: Draft Posts using Computed Data
- View all of the Eleventy Quick Tips.