-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
eleventy.bundle.js
36 lines (28 loc) · 1.01 KB
/
eleventy.bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const pkg = require("./package.json");
const shortcodesPlugin = require("./eleventy.shortcodes.js");
function normalizeOptions(options = {}) {
options = Object.assign({
// Plugin defaults
bundles: [], // extra bundles: css, js, and html are guaranteed
toFileDirectory: "bundle",
// post-process
transforms: []
}, options);
options.bundles = Array.from(new Set(["css", "js", "html", ...(options.bundles || [])]));
return options;
}
function eleventyBundlePlugin(eleventyConfig, options = {}) {
try {
eleventyConfig.versionCheck(pkg["11ty"].compatibility);
} catch(e) {
console.log( `WARN: Eleventy Plugin (${pkg.name}) Compatibility: ${e.message}` );
}
options = normalizeOptions(options);
shortcodesPlugin(eleventyConfig, options);
};
// This plugin is used to find the package name for this plugin (used by eleventy-plugin-webc)
Object.defineProperty(eleventyBundlePlugin, "eleventyPackage", {
value: pkg.name
});
module.exports = eleventyBundlePlugin;
module.exports.normalizeOptions = normalizeOptions;