Less Bundle Promise

1.0.11 · abandoned · verified Tue Apr 21

Less Bundle Promise (less-bundle-promise) is a JavaScript utility designed to bundle multiple LESS files into a single output file. Primarily targeting larger projects with modular LESS structures, it offered a promise-based API for asynchronous compilation when it was actively maintained. The package, currently at version `1.0.11`, was last published approximately 4 years ago (as of 2026), indicating it is no longer actively developed or maintained. Its key differentiator at the time was the use of Promises for managing asynchronous Less compilation, which was a modern pattern for Node.js workflows. However, due to its abandonment, it lacks updates for newer Less features, Node.js versions, or modern module systems like ESM, making it largely unsuitable for contemporary projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `less-bundle-promise` to compile multiple Less files into a single output, either printed to the console or written to a specified destination file. It showcases both the basic usage and the `writeFile` option, including creation of a temporary file structure for a runnable example.

const bundle = require('less-bundle-promise');
const fs = require('fs');
const path = require('path');

// Create a dummy main.less file for demonstration
const mainLessContent = `
@import "./components/button.less";
@import "./theme/colors.less";

body {
  font-family: Arial, sans-serif;
  .button-style;
  background-color: @primary-color;
}
`;
const buttonLessContent = `
.button-style {
  padding: 10px 15px;
  border: 1px solid black;
  border-radius: 5px;
  color: white;
}
`;
const colorsLessContent = `
@primary-color: #3498db;
@secondary-color: #2ecc71;
`;

const tempDir = path.join(__dirname, 'temp_less_project');
const componentsDir = path.join(tempDir, 'components');
const themeDir = path.join(tempDir, 'theme');

fs.mkdirSync(componentsDir, { recursive: true });
fs.mkdirSync(themeDir, { recursive: true });
fs.writeFileSync(path.join(tempDir, 'main.less'), mainLessContent);
fs.writeFileSync(path.join(componentsDir, 'button.less'), buttonLessContent);
fs.writeFileSync(path.join(themeDir, 'colors.less'), colorsLessContent);

// Bundle Less files and print to console
bundle({
    src: path.join(tempDir, 'main.less')
}).then(output => {
  console.log('--- Bundled LESS Output (to console) ---');
  console.log(output);
  console.log('----------------------------------------');
})
.catch(error => {
  console.error('Error bundling LESS:', error);
});

// Bundle Less files and write to a destination file
const destPath = path.join(tempDir, 'bundle.less');
bundle({
    src: path.join(tempDir, 'main.less'),
    dest: destPath,
    writeFile: true
}).then(output => {
  console.log(`Bundle successfully written to ${destPath}`);
  console.log('--- Content of bundle.less ---');
  console.log(fs.readFileSync(destPath, 'utf8'));
  console.log('------------------------------');
})
.catch(error => {
  console.error('Error writing bundled LESS to file:', error);
});

// Clean up temporary files (optional, for a real quickstart you might omit cleanup for user inspection)
// setTimeout(() => {
//   fs.rmSync(tempDir, { recursive: true, force: true });
//   console.log('Cleaned up temporary directory.');
// }, 2000);

view raw JSON →