brovite
v1.3.1
Published
A lightweight Vite-like dev tool and bundler for mobile editors like Acode
Maintainers
Readme
⚡ brovite
A lightweight Vite-like development tool and bundler designed to work especially well in mobile editors like Acode and Termux.
Features
- ⚡ ES Module support — write modern
import/exportsyntax - 🔗 Recursive bundling — resolves the full dependency graph automatically
- 🔄 Live reload — browser auto-refreshes on file save via WebSocket
- 🛠 Dev server — instant local HTTP server with module transformation
- 📦 Standard build — outputs a single
bundle.js+index.html - 💼 Professional build — full node_modules resolution, JSX, TypeScript, fonts, images
- 👀 Preview server — serve your built app locally before deploying
- 🔌 Plugin API — extend with custom transform hooks
- 🎨 Clean terminal output — colourised logs via picocolors
Installation
npm install -g broviteAfter installation, run brovite from any project directory. esbuild is included — no extra installs needed.
Quick Start
mkdir my-app && cd my-app
cat > main.js << 'EOF'
import { greet } from './utils.js'
greet('World')
EOF
cat > utils.js << 'EOF'
export function greet(name) {
console.log(`Hello, ${name}!`)
}
EOF
brovite dev
# → http://localhost:3000CLI Commands
brovite dev [entry]
Start the development server with live reload.
brovite dev # entry: main.js, port: 3000
brovite dev src/main.js # custom entry
brovite dev --port 8080 # custom port
brovite dev --host 0.0.0.0 # expose to network (test on phone)
brovite dev --open # open browser automatically| Option | Default | Description |
|--------|---------|-------------|
| --port <n> | 3000 | HTTP port |
| --host <h> | localhost | HTTP host |
| --open | false | Open in browser |
brovite build [entry]
Bundle the project for production.
brovite build # standard build
brovite build --professional # full build with node_modules, JSX, fonts
brovite build --professional --minify # + minify output
brovite build src/main.jsx --professional| Option | Default | Description |
|--------|---------|-------------|
| --professional | false | Use esbuild engine (see below) |
| --outDir <dir> | dist | Output directory |
| --minify | false | Minify bundle |
| --sourcemap | false | Emit inline source map |
Output:
dist/
├── bundle.js ← all modules concatenated / bundled
├── bundle.css ← extracted CSS (professional mode)
└── index.html ← ready to open in browserbrovite preview
Serve the production build locally.
brovite preview # serves dist/ on port 4173
brovite preview --port 5000 # custom port
brovite preview --dir out # custom directoryStandard vs Professional Build
Standard brovite build
Brovite's own lightweight bundler. Best for simple projects with only your own files.
- ✅ Your own
.jsfiles - ✅ Relative imports (
./utils.js) - ✅ No extra dependencies needed
- ❌ Cannot resolve
node_modules - ❌ No JSX / TypeScript
Professional brovite build --professional
Uses esbuild under the hood. Best for real projects with npm packages.
- ✅ Everything in standard mode
- ✅
node_modulesresolution (import react from 'react') - ✅ React / Vue / Preact / Solid JSX
- ✅ TypeScript (
.ts,.tsx) - ✅ Fonts inlined as base64 (no missing font errors)
- ✅ Images inlined as base64
- ✅ CSS bundling and extraction
- ✅ Reads
vite.config.jsif present - ✅ Copies
public/folder todist/ - ✅ Handles malformed
package.jsonfiles gracefully - ✅ Tree shaking
ES Module Example
utils.js
export function greet(name) {
console.log(`Hello, ${name}!`)
}main.js
import { greet } from './utils.js'
greet('brovite')Bundled output (dist/bundle.js)
function greet(name) {
console.log(`Hello, ${name}!`)
}
greet('brovite')Vite Project Compatibility
brovite works as a drop-in dev server for existing Vite projects:
# Instead of: vite
brovite dev
# Instead of: vite build
brovite build --professional
# Instead of: vite preview
brovite previewThe dev server automatically:
- Resolves bare imports (
import vue from 'vue') fromnode_modules - Transforms JSX and TypeScript on-the-fly
- Reads
vite.config.jsfor compatible settings - Serves unknown routes with
index.html(SPA fallback)
React Project Example
npx create-react-app my-app
cd my-app
npm install
brovite dev # dev server with live reload
brovite build # static handle only css,js,html,module
brovite build --professional # production bundle
brovite preview # preview the buildFont and Asset Handling
In professional mode, brovite automatically converts fonts and images referenced in CSS with absolute paths into base64 data URLs — so they always work in the bundle, even without a server.
Before (your CSS):
@font-face {
font-family: 'Retro Gaming';
src: url('/fonts/Retro Gaming.ttf');
}After (in bundle.css):
@font-face {
font-family: 'Retro Gaming';
src: url('data:font/ttf;base64,AAAB...');
}No missing font errors. No extra files to copy.
Acode / Termux Usage
brovite is optimised for Android development via Termux:
# Install Termux from F-Droid, then:
npm install -g brovite
# Navigate to your project
cd /storage/emulated/0/myapp
# Start dev server (accessible from device browser)
brovite dev --host 0.0.0.0
# Open http://localhost:3000 in your Android browserFor Acode's built-in preview (no server):
brovite build
# Open dist/index.html directly in Acode previewPlugin API
const myPlugin = {
name: 'my-plugin',
// Transform module source before bundling
transform(code, id) {
return code.replace(/__VERSION__/g, '1.0.0')
},
// Resolve a custom import specifier
resolveId(specifier, importer) {
if (specifier === 'virtual:data') return '\0virtual:data'
return null
},
// Load content for a resolved id
load(id) {
if (id === '\0virtual:data') return 'export const data = [1, 2, 3]'
return null
},
buildStart() {},
buildEnd() {},
}Architecture
brovite/
├── cli.js ← Binary entry (#!/usr/bin/env node)
└── src/
├── cli/commands.js ← CLI (cac) — dev / build / preview
├── bundler/
│ ├── bundle.js ← Standard build orchestrator
│ ├── professionalBuild.js ← Professional build (esbuild-powered)
│ ├── moduleGraph.js ← Recursive dependency resolver
│ ├── parser.js ← ES module import/export parser
│ └── transform.js ← Import/export rewriter
├── server/
│ ├── devServer.js ← Dev HTTP server + bare import resolver
│ ├── previewServer.js ← Static file server
│ └── websocket.js ← WebSocket HMR + browser client
├── watcher/watcher.js ← File watcher (chokidar)
├── plugins/pluginContainer.js ← Plugin runner
└── utils/
├── logger.js ← Terminal output (picocolors)
├── resolve.js ← node_modules resolver
├── viteCompat.js ← Vite config reader + framework detector
├── path.js ← Path helpers
└── fs.js ← Async fs + MIME typesDependencies
| Package | Role | |---------|------| | esbuild | Professional bundler — JSX, TS, node_modules | | cac | CLI argument parsing | | chokidar | File watching | | es-module-lexer | Fast import/export parsing | | magic-string | Source-map-friendly code transforms | | ws | WebSocket HMR server | | picocolors | Terminal colours |
Changelog
v1.2.0
- Fixed: malformed
package.jsonwith GNU license headers no longer crashes the build - Fixed: absolute font/image paths in CSS (
/fonts/Retro Gaming.ttf) are now inlined as base64 - Added:
public/folder is automatically copied todist/in professional mode - Added: better framework detection (React 16 vs 17 JSX transform)
v1.1.0
- Added:
brovite build --professionalusing esbuild - Added: bare import resolution in dev server (
import vue from 'vue') - Added: JSX/TypeScript support in dev mode
- Added: Vite project compatibility
- Fixed:
brovite previewcommand not running (cac parsing bug) - Fixed:
Permission deniedon Termux (chmod in prepare script)
v1.0.0
- Initial release
License
MIT
