Substance Bundler is a custom JavaScript bundling and build orchestration library, currently at version `0.27.4`. It offers a high-level, shell-script-like approach to defining build processes, distinguishing itself from traditional task runners like Gulp or Grunt by emphasizing simplicity and direct action execution. The library internally leverages `chokidar` for robust file watching, ensuring all defined operations automatically react to source file changes. While not a bundler itself, it seamlessly integrates with popular tools such as Webpack, Rollup, and PostCSS via dedicated extensions, acting as an orchestrator for these underlying technologies. This allows developers to define complex build pipelines, including copying files, removing directories, and executing custom scripts, all within a unified task-based system with inter-task dependencies. Its primary differentiator lies in its low-ceremony API for defining build steps and its integrated watch mode across all tasks, offering a streamlined development experience for projects that require custom but maintainable build logic.
npm install substance-bundlerVerified import paths — ran on the pinned version, not inferred.
This `make.js` script demonstrates defining and orchestrating multiple build tasks, including cleaning, CSS compilation via PostCSS, JavaScript bundling with Rollup, and file copying, all managed by `substance-bundler`. It showcases task dependencies and a basic command-line runner for build operations.
Always use `const b = require('substance-bundler')` and `const extension = require('substance-bundler/extensions/...')` in your build scripts. Ensure your script is treated as a CommonJS module.Ensure you `npm install --save-dev <package-name>` (e.g., `rollup`, `webpack`, `postcss`) for any extensions you use in your build tasks.
For `b.copy` operations involving glob patterns, explicitly define `options.root` to specify the base directory from which source files are resolved.
Replace `fs.writeFileSync(path, data)` with `api.writeFileSync(path, data)` and similar `fs` calls with `api` methods within `b.custom` task `execute` functions to ensure proper bundler integration.
Change your import statement to `const b = require('substance-bundler')`. If your entire project is ESM, you might need to wrap your `substance-bundler` script in a CommonJS context or adjust your module resolution.Install the missing package as a development dependency: `npm install --save-dev rollup` (or `webpack`, `postcss`).
Ensure your 'clean' task (e.g., `b.rm('dist')`) is configured as a dependency and runs before tasks that create build output directories, or explicitly add logic to skip directory creation if it already exists.Verify that the glob pattern in your `src` path is correct, that the specified directory exists, and that the intended source files are present at that location relative to your `make.js` script.