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
- entry string: it should be in the same folder as your bundler file
- 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 the entry point of your app
- 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
- decoder? fuction: it uses TextDecoder by default
Arguments marked with a question mark (?) are optional
Example
buckets.ts:
export default {
key: "my-key",
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://raw.githubusercontent.com/jacoborus/deno-buckets/main/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://raw.githubusercontent.com/jacoborus/deno-buckets/main/mod.ts";
await bundle(conf);TODO
- Tests
- Remove extensions
- Custom decoders
- Docs
- Logo
- CI
- Release
- Return nicer errors
- Add generic constraints
© 2021 Jacobo Tabernero Rey - Released under MIT License