Repository
Current version released
5 years ago
Dependencies
std
Asset bundler for Deno apps
deno-buckets
Usage
This library exports 2 methods: loadBuckets and bundle. The first one
exposes a tree with the contents of your folders and the second one bundles the
app with all the assets. Both methods require the bundle options as unique
parameter.
BundleOptions:
- key string: this avoids stores clashing
- optionsUrl string:
import.meta.url - entry string: relative to config folder
- output string: if you omit this, the bundle will be sent to stdout
- buckets BucketOptions[]: a list of bucket configurations. See below
BucketOptions:
- name string: for future reference
- folder string: relative to config folder
- maxDepth? number: by default, there’s no limit
- exts?: string[]: a list of extensions to filter in.
- match?: RegExp[]: a list of regexes to filter in
- skip?: RegExp[]: a list of regexes to filter out
- trimExtensions? boolean: remove the extension from the file name.
Requires option
exts - decoder? fuction: it uses TextDecoder by default
Arguments marked with a question mark (?) are optional
Example
buckets.ts:
export default {
key: "my-key",
optionsUrl: import.meta.url,
entry: "app.ts",
buckets: [
{
name: "data",
folder: "countries",
},
{
name: "mustaches",
folder: "assets/mustaches/templates",
exts: [".template"],
trimExtensions: true,
},
],
output: "app.bundle.js",
};app.ts:
import { loadBuckets } from "https://deno.land/x/buckets@0.1.0/mod.ts";
import bucketsConf from "./buckets.ts";
const buckets = loadBuckets(bucketsConf);
console.log(buckets);
// {
// mustaches: {
// "country-info": ".....",
// "other-info": ".....",
// ...
// },
// data: {
// "capitals.txt": ".....",
// "population.txt": ".....",
// ...
// }
// }bundler.ts:
import conf from "./buckets.ts";
import { bundle } from "https://deno.land/x/buckets@0.1.0/mod.ts";
await bundle(conf);TODO
- Allow to create buckets from handpicked paths
- Return nicer errors
- Add generic constraints
© 2021 Jacobo Tabernero Rey - Released under MIT License