Felt: On-demand ES6/CSS Bundler

0.3.2 · active · verified Tue Apr 21

Felt is an on-demand bundler designed for modern JavaScript (ES6 and beyond, typically transpiled via Buble/Rollup) and CSS (CSS Next), serving primarily as a development middleware or a static asset exporter. Currently at version 0.3.2, it requires Node.js 6 or above to run. The package offers three main modes of operation: a standalone CLI web server for quick local development, an Express.js middleware for integration into existing Node.js applications, and a static file exporter for pre-compiling assets for deployment. Its core functionality is highly extensible through 'recipes' and a plugin architecture, exemplified by modules like `felt-rollup`, which allows developers to define custom handler logic for different file types. This on-demand compilation approach is a key differentiator, focusing on speed during development rather than exhaustive pre-bundling.

Common errors

Warnings

Install

Imports

Quickstart

Integrates Felt as an on-demand ES6/CSS bundler middleware with an Express.js server.

const express = require('express');
const felt = require('felt');
const path = require('path');
const config = require('./felt.config.js'); // Assuming felt.config.js exists and exports a Felt config object

const app = express();

// Integrate Felt as an on-demand bundling middleware
app.use(felt(config));

// Serve static files from the 'public' directory
app.use(express.static(path.join(__dirname, 'public')));

const PORT = process.env.PORT ?? 3000;
app.listen(PORT, () => {
  console.log(`Felt server running at http://localhost:${PORT}`);
  console.log('Serving static files from ./public and bundling JavaScript/CSS on-demand.');
});

// To set up:
// 1. npm install express felt felt-rollup rollup-plugin-buble rollup-plugin-node-resolve rollup-plugin-commonjs
// 2. Create 'felt.config.js' (as shown in the README example)
// 3. Create 'public/index.html' and 'public/main.js' (e.g., 'console.log("Hello from Felt!")')
// 4. Run with 'node server.js'

view raw JSON →