Skip to content

Commit

Permalink
Rename the root plugin file
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Feb 2, 2023
1 parent 37efb1e commit 2f64061
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 35 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Makes implementing Critical CSS, per-page in-use-only CSS/JS bundles, SVG icon l

## Why?

This project is a minimum-viable-plugin for an asset pipeline in Eleventy. It does not perform any transpilation or code manipulation. The code you put in is the code you get out (with configurable hooks for more).
This project is a minimum-viable-bundler and asset pipeline in Eleventy. It does not perform any transpilation or code manipulation (by default). The code you put in is the code you get out (with configurable `transforms` if you’d like to modify the code).

For more complex features you may want to use a more full featured bundler like Vite, Parcel, Webpack, rollup, esbuild, or others.
For more larger, more complex use cases you may want to use a more full featured bundler like Vite, Parcel, Webpack, rollup, esbuild, or others.

Bundling has a significant build performance cost, so take care to weigh the cost of using a full-featured Bundler against whether or not this plugin has sufficient functionality for your needs—especially as the platform matures and we see diminishing returns on code transpilation.
But do note that a full-featured bundler has a significant build performance cost, so take care to weigh the cost of using that style of bundler against whether or not this plugin has sufficient functionality for your use case—especially as the platform matures and we see diminishing returns on code transpilation (ES modules everywhere).

## Installation

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@11ty/eleventy-plugin-bundle",
"version": "1.0.0",
"description": "Little bundles of code, little bundles of joy.",
"main": "eleventy.config.js",
"main": "eleventy.bundle.js",
"scripts": {
"sample": "DEBUG=Eleventy:Bundle npx @11ty/eleventy --config=sample/sample-config.js --input=sample",
"test": "npx ava"
Expand Down
48 changes: 17 additions & 31 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ function normalize(str) {
}

test("CSS (Nunjucks)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/nunjucks/");
let elev = new Eleventy("test/stubs/nunjucks/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
Expand All @@ -26,8 +25,7 @@ test("CSS (Nunjucks)", async t => {
});

test("CSS (Liquid)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/liquid/");
let elev = new Eleventy("test/stubs/liquid/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
Expand All @@ -41,8 +39,7 @@ test("CSS (Liquid)", async t => {
});

test("CSS (Markdown)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/markdown/");
let elev = new Eleventy("test/stubs/markdown/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
Expand All @@ -56,8 +53,7 @@ test("CSS (Markdown)", async t => {
});

test("CSS (Handlebars)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/handlebars/");
let elev = new Eleventy("test/stubs/handlebars/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
Expand All @@ -74,17 +70,15 @@ test("CSS (Handlebars)", async t => {
});

test("SVG", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/nunjucks-svg/");
let elev = new Eleventy("test/stubs/nunjucks-svg/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<svg width="0" height="0" aria-hidden="true" style="position: absolute;">
<defs><g id="icon-close-legacy"><path d="M8,15 C4.13400675,15 1,11.8659932 1,8 C1,4.13400675 4.13400675,1 8,1 C11.8659932,1 15,4.13400675 15,8 C15,11.8659932 11.8659932,15 8,15 Z M10.44352,10.7233105 L10.4528296,10.7326201 L10.7326201,10.4528296 C11.0310632,10.1543865 11.0314986,9.66985171 10.7335912,9.37194437 L9.36507937,8.0034325 L10.7360526,6.63245928 C11.0344957,6.33401613 11.0349311,5.84948135 10.7370237,5.55157401 L10.448426,5.26297627 C10.1505186,4.96506892 9.66598387,4.96550426 9.36754072,5.26394741 L8.00589385,6.62559428 L6.63738198,5.25708241 C6.33947464,4.95917507 5.85493986,4.95961041 5.55649671,5.25805356 L5.26737991,5.54717036 C4.96893676,5.84561351 4.96850142,6.33014829 5.26640876,6.62805563 L6.62561103,7.9872579 L5.25463781,9.35823112 C4.95619466,9.65667427 4.95575932,10.141209 5.25366666,10.4391164 L5.5422644,10.7277141 C5.84017175,11.0256215 6.32470652,11.0251861 6.62314967,10.726743 L7.99412289,9.35576976 L9.36263476,10.7242816 C9.66054211,11.022189 10.1450769,11.0217536 10.44352,10.7233105 Z" /></g></defs>
</svg>`)
});

test("JS", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/liquid-js/");
let elev = new Eleventy("test/stubs/liquid-js/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<script>alert(1);
alert(2);
Expand All @@ -98,8 +92,7 @@ alert(3);</script>`)
});

test("CSS, two buckets", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/liquid-buckets/");
let elev = new Eleventy("test/stubs/liquid-buckets/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: orange; }</style>
Expand All @@ -108,8 +101,7 @@ test("CSS, two buckets", async t => {
});

test("CSS, two buckets, explicit `default`", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/liquid-buckets-default/");
let elev = new Eleventy("test/stubs/liquid-buckets-default/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: orange; }</style>
Expand All @@ -119,35 +111,31 @@ test("CSS, two buckets, explicit `default`", async t => {
});

test("CSS, get two buckets at once", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/buckets-get-multiple/");
let elev = new Eleventy("test/stubs/buckets-get-multiple/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: orange; }
* { color: red; }</style>`); // note that blue is only listed once, we de-dupe entries across buckets
});

test("CSS, get two buckets at once, reverse order", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/buckets-ordering/");
let elev = new Eleventy("test/stubs/buckets-ordering/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
* { color: orange; }</style>`); // note that blue is only listed once, we de-dupe entries across buckets
});

test("CSS, get two buckets at once (comma separated list)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/buckets-get-multiple-comma-sep/");
let elev = new Eleventy("test/stubs/buckets-get-multiple-comma-sep/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: orange; }
* { color: red; }</style>`); // note that blue is only listed once, we de-dupe entries across buckets
});

test("toFile Filter (no writes)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/to-file/");
let elev = new Eleventy("test/stubs/to-file/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<style>* { color: blue; }
* { color: red; }
Expand All @@ -159,8 +147,8 @@ test("toFile Filter (no writes)", async t => {
});

test("toFile Filter (write files)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/to-file-write/", undefined, {
configPath: "eleventy.bundle.js",
config: function(eleventyConfig) {
eleventyConfig.setQuietMode(true);
}
Expand All @@ -186,8 +174,8 @@ test("toFile Filter (write files)", async t => {
});

test("toFile Filter (write files, out of order)", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/to-file-ordering/", undefined, {
configPath: "eleventy.bundle.js",
config: function(eleventyConfig) {
eleventyConfig.setQuietMode(true);
}
Expand All @@ -211,17 +199,16 @@ test("toFile Filter (write files, out of order)", async t => {
});

test("Bundle in Layout file", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/bundle-in-layout/");
let elev = new Eleventy("test/stubs/bundle-in-layout/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<!doctype html><html><head><link href="https://v1.opengraph.11ty.dev" rel="preconnect" crossorigin></head></html>`);
});

test("Bundle with render plugin", async t => {
const sass = require("sass");

// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/bundle-render/", undefined, {
configPath: "eleventy.bundle.js",
config: function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyRenderPlugin);

Expand Down Expand Up @@ -249,8 +236,7 @@ h1 .test {
});

test("No bundling", async t => {
// automatically uses eleventy.config.js in root
let elev = new Eleventy("test/stubs/no-bundles/");
let elev = new Eleventy("test/stubs/no-bundles/", null, { configPath: "eleventy.bundle.js" });
let results = await elev.toJSON();
t.deepEqual(normalize(results[0].content), `<!doctype html>
<html lang="en">
Expand Down

0 comments on commit 2f64061

Please sign in to comment.