npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bun-bundler

v0.1.18

Published

Bun-Bundler: Modern, Simple, and Ultra-Fast HTML Bundler. Bun | Pug/HTML | SCSS/CSS | JS | SVG Sprite | Image optimizations

Downloads

86

Readme

Bun-Bundler: Modern, Simple, and Ultra-Fast HTML Bundler

Bun Node.js

Bun-Bundler is a powerful and efficient HTML bundler designed for modern web development. It offers a comprehensive solution for bundling and optimizing your web projects, with support for various technologies and features that streamline your development workflow.

Key Features

  • Pug / HTML support for flexible templating
  • SCSS / CSS preprocessing
  • JavaScript bundling and optimization
  • SVG Sprite generation
  • Image optimizations for improved performance
  • Static assets handling
  • Real-time file watching and hot reloading for rapid development

Why Choose Bun-Bundler?

Bun-Bundler was created to address the limitations of other popular bundlers. It offers:

  • Efficiency: Ultra-fast bundling and optimization processes
  • Flexibility: Easy integration with other Node.js scripts and modules
  • Scalability: Suitable for both small projects and large-scale websites
  • PUG Support: Built-in support for the PUG templating engine, enabling efficient front-end development

Quick Start

Installation

npm install bun-bundler

or

bun add bun-bundler

Basic Configuration

Create a build.mjs file in your project root with the following content:

import path from 'path';
import { Bundler } from 'bun-bundler';
import { SpriteBuilder, ImageProcessor, Server } from 'bun-bundler/modules';

const bundler = new Bundler();
const spriteBuilder = new SpriteBuilder();
const imgProcessor = new ImageProcessor();

// Define your project structure
const src = path.resolve('./src');
const dist = path.resolve('./build');

const directories = {
	src: src,
	html: path.resolve(src, './pug/pages/'),
	sass: [path.resolve(src, './scss/app.scss')],
	js: [path.resolve(src, './js/app.js')],
	images: path.resolve(src, './images/'),
	fonts: path.resolve(src, './fonts/'),
	statics: path.resolve(src, './static/'),

	dist: dist,
	htmlDist: dist,
	cssDist: path.resolve(dist, './css/'),
	jsDist: path.resolve(dist, './js/'),
	imagesDist: path.resolve(dist, './images/'),
	spriteDist: path.resolve(dist, './images/sprite'),
};

const { images, fonts, statics } = directories;

// Configure the bundler
bundler.build({
	...directories,
	// ❇️ You can pass function(it will call on every render), or array of files
	html: () => Bundler.utils.getDirFiles(directories.html),
	staticFolders: [images, fonts, statics],
	production: process.env.NODE_ENV === 'production',
	onBuildComplete: () => {
		imgProcessor.process({ root: directories.imagesDist });
		spriteBuilder.build({
			htmlDir: directories.dist,
			dist: directories.spriteDist,
		});
	},
});

We're ready to takeoff! Run bun run build.mjs

Development Mode

To enable file watching and dev-mode, use the following configuration: dev.mjs

const debugMode = false;
const server = new Server();

bundler.watch({
	...directories,
	production: process.env.NODE_ENV === 'production',
	staticFolders: [images, fonts, statics],
	debug: debugMode,
	html: () => Bundler.utils.getDirFiles(directories.html),
	onStart: () => {
		server.startServer({
			open: true,
			debug: debugMode,
			port: 8080,
			root: dist,
			❇️ // custom BrowserSync config, if needed:
			overrides: {},
		});
	},
	onBuildComplete: () => {
		// ❇️ image optimizations on every build (no caching)
		imgProcessor.process({
			debug: debugMode,
			root: directories.imagesDist,
		});
		// ❇️ refresh sprite on every build (no caching)
		spriteBuilder.build({
			debug: debugMode,
			htmlDir: dist,
			dist: directories.spriteDist,
		});
	},
	onCriticalError: () => {
		server.stopServer();
	},
});

Run bun run dev.mjs

Examples and Boilerplate

  • Check the ./examples directory in the repository to see Bun-Bundler in action.
  • For a production-ready boilerplate, visit Glivera Bun Template.

Contributing

We welcome contributions! Feel free to open issues or submit pull requests to help improve Bun-Bundler.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❤️ by the Bun-Bundler team. Happy bundling!