primer-module-build is a JavaScript package developed by GitHub, forming a core part of the Primer CSS ecosystem. Its primary function is to compile Primer SCSS modules into production-ready CSS, apply PostCSS transformations, and generate build statistics. Currently at version 2.0.0, the package provides both a command-line interface (CLI) for automated build processes and a programmatic API for more integrated workflows. It is essential for projects leveraging Primer CSS, offering a streamlined approach to asset compilation and optimization. While no explicit release cadence is published, it aligns with the broader Primer CSS development. Its key differentiator lies in its specialized design for the Primer framework, ensuring compatibility and leveraging internal conventions for efficient styling pipelines.
npm install primer-module-buildVerified import paths — ran on the pinned version, not inferred.
Demonstrates both programmatic usage of the 'build' function to compile an SCSS file and mentions its CLI equivalent. This showcases a typical build flow, including path resolution and error handling.
Ensure your Node.js environment is compatible with `node-sass` or consider using `sass` (Dart Sass) if migrating away from `node-sass` is feasible for your project. If you encounter issues, try `npm rebuild node-sass` or `yarn rebuild node-sass`.
Review the package's source code and configuration files (e.g., `cli.js`, `index.js`) to understand its default behavior and adapt `primer.json` and `postcss.config.js` to your project's specific needs if not within the Primer framework.
When developing with `primer-module-build`, ensure it is used as a development dependency (`npm install --save-dev primer-module-build`) within the root of your project, and that the necessary SCSS source files and configurations are accessible relative to where the build command is executed. Do not try to run its internal build scripts from within `node_modules`.
Delete `node_modules` and `package-lock.json` (or `yarn.lock`), then run `npm install` (or `yarn install`) to re-download and recompile `node-sass` for your current Node.js version. If that fails, try `npm rebuild node-sass` directly.
Ensure `postcss` is correctly listed in `dependencies` or `devDependencies` in your `package.json` and run `npm install` (or `yarn install`) to install it. Verify that the module is present in `node_modules`.
Create a `primer.json` file in your project root or in a path where `find-up` can locate it. Refer to the `primer-module-build` documentation or source for the expected structure of this configuration file. Alternatively, ensure you are passing the correct options if using the programmatic API.