eleventy-plugin-bundle icon indicating copy to clipboard operation
eleventy-plugin-bundle copied to clipboard

Add examples for `bundleExportKey` feature to docs

Open zachleat opened this issue 1 year ago • 3 comments

bundleExportKey: "bundle" (default) means that you can do this in your 11ty.js template:

export const bundle = {
	css: "/* Only adds to css bundle */"
};

export function render() {};
export function data() {};

This works with buckets too, if you nest another object in your export:

export const bundle = {
  css: {
    default: "/* Only adds to default bucket in css bundle */"
  }
};

This works too but probably isn’t what you want:

export const bundle = "/* Adds to all bundles using bundleExportKey: "bundle" */";

This makes more sense, if you want to opt-in to something a bit simpler with a string export direct to a bundle:

bundleExportKey: "css" means that you can do this in your 11ty.js template:

export const css = "/* Some CSS */";

zachleat avatar Jul 05 '24 20:07 zachleat

It should be added a function for this like ``{% css {append:true,bucket:'defer'} %}` or similar, I wonder why this is implemented by default?

Dexus avatar Feb 26 '25 15:02 Dexus

btw. If you work with the tailwindcss v4 you cant work with this style because you always have to resolve to your main css... so it does not work within the content.11tydata.js when we need to resolve to the main.css like @reference '../../public/css/_index.css';

Dexus avatar Feb 26 '25 15:02 Dexus

Better would be a additional pairshortcode like ${bundleName}_append

Dexus avatar Feb 26 '25 16:02 Dexus