Getting Started
Create your first Bundle.js project with a simple configuration script and instant hot module reloading out of the box.
npm
init
npm create -i
# or install globally
npm install -g bundle.js
Core Concepts
Tree Shaking
Automatically removes unused code to minimize your final bundle size.
Code Splitting
Split your bundle into multiple files for better performance and load times.
Example Configuration File
// bundle.config.js
export default {
input: './src/index.js',
output: {
file: 'bundle.js',
format: 'esm'
}
}
API Reference
bundle.config
Primary configuration object
input:
stringoutput:
objectplugins:
arraywatch:
boolean
build()
Bundles files and outputs to file system
src:
stringdest:
stringenv:
'dev' | 'prod' | 'test'
watch()
Watches file changes and rebundles
src:
stringwatcher:
functiondelay:
number
Advanced Usage
TypeScript Configuration
// bundle.config.ts
import { config } from 'bundle.js';
const config: BundleConfig = {
input: './src/index.ts',
output: {
dir: './dist',
format: 'esm',
sourcemap: true
},
plugins: [typescript()],
watch: {
enabled: true,
delay: 300
}
};