An open API service indexing awesome lists of open source software.

https://github.com/joegasewicz/warden

Static builder & bundler CLI
https://github.com/joegasewicz/warden

build-tool bundler cli dart dartlang js-bundle js-bundler

Last synced: 6 months ago
JSON representation

Static builder & bundler CLI

Awesome Lists containing this project

README

          

![pub package](https://img.shields.io/pub/v/warden.svg)
![Dart](https://img.shields.io/badge/Dart-3.7%2B-blue)


Warden

**Static builder & bundler for Dart projects**

Warden is a lightweight CLI tool to watch and compile Dart and Sass files for frontend projects that don’t use Flutter, are focused on building to JavaScript for server-side rendered apps, and work with Node-installed packages. It’s ideal for projects that still want custom JS/CSS assets compiled automatically.

πŸ“š Docs: [pub.dev/packages/warden](https://pub.dev/packages/warden)

---

## ✨ Features

- πŸ” Watches your Dart and Sass files and recompiles on change
- πŸ“¦ Moves specified dependencies (e.g. node_modules assets) into your build output
- πŸ—‚οΈ Moves specified asset directories (e.g. `assets/img/`) into your build output
- πŸ› οΈ Bundles your dependency JS files into a single `bundle.js` (optional)
- 🧱 Fully configurable via a `warden.yaml` file
- 🎯 Supports multiple tasks like compiling Dart to JS and Sass to CSS

---

![Screenshot](example/screen2.png)

---

## βš™οΈ Setup

Create a `warden.yaml` in your project root:

```yaml
# The root directory of your source files
source_dir: examples

# Where to output built files (JavaScript, CSS, etc.)
destination: static/

main_file: static/main.js # Main Dart-built JS file

# Dependency handling (e.g. node_modules)
dependencies:
- source: example/node_modules
bundle: true
files:
- "poppyjs/dist/Poppy.min.js"
- "bootstrap/dist/js/bootstrap.min.js"
- "bootstrap/scss/bootstrap.scss"
- source: example/another
bundle: true
files:
- "lib1/dep1.js"
- "lib2/dep2.js"

# (Optional) Copies across assets folders (e.g. containing .png, .jpg) to the destination directory
assets:
source: example/assets
directories: # The directory in source path that you want to copy across to the destination directory
- img

# Tasks to run
tasks:
frontend:
executable: dart
args: ["compile", "js", "bin/main.dart", "-o", "../static/main.js"]
src: examples # Working directory for Dart files

styles:
executable: dart
args: ["run", "sass", "sass/index.scss:../static/index.css"]
src: examples # Working directory for Sass
warnings: false # Optional: suppress warnings for this task (default is true)
```

### ▢️ Running
Run Warden from your terminal in watch mode:
```
dart run warden --file=warden.yaml
```
This will:
β€’ Move files listed in dependencies.files into the output directory
β€’ Bundle them into a single bundle.js if bundle: true
β€’ Compile Dart to JS
β€’ Compile Sass to CSS
β€’ Watch and recompile on file changes

### πŸ“¦ Installation

```bash
dart pub global activate warden
```
Then run from any Dart project:
```bash
warden --file=warden.yaml
```

### πŸ§ͺ Example Project Structure
```
examples/
β”œβ”€β”€ bin/
β”‚ └── main.dart
β”œβ”€β”€ lib/
β”‚ └── examples.dart
β”œβ”€β”€ sass/
β”‚ └── index.scss
β”œβ”€β”€ node_modules/
β”œβ”€β”€ warden.yaml
```

### Contributions
Please open an issue or reply to an existing issue requesting that you would like
to work on it. PRs that do not fix a known bug or add new features will be closed.

License

MIT Β© 2025 joegasewicz