{"library":"primer-module-build","title":"Primer Module Build","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install primer-module-build"],"cli":{"name":"primer-module-build","version":null}},"imports":["import { build } from 'primer-module-build';","import { watch } from 'primer-module-build';","// Used via command line: primer-module-build <file.scss>"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { build } from 'primer-module-build';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\n// In a real project, replace 'your-module.scss' with the actual path.\n// This example assumes you have an SCSS file to compile.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\nconst scssFilePath = path.join(__dirname, 'test-module.scss'); // Assuming test-module.scss exists\nconst outputDir = path.join(__dirname, 'build');\n\n// Example SCSS content for test-module.scss\n// $color: #f00;\n// .test-class {\n//   color: $color;\n//   .nested {\n//     font-weight: bold;\n//   }\n// }\n\nasync function runBuild() {\n  try {\n    console.log(`Building SCSS from ${scssFilePath}...`);\n    await build(scssFilePath, {\n      outputPath: outputDir,\n      // Other options like 'sourceMap' can be passed here\n    });\n    console.log(`Build complete. CSS and stats generated in ${outputDir}/`);\n    console.log('You can also run this from the command line:');\n    console.log(`npx primer-module-build ${scssFilePath}`);\n  } catch (error) {\n    console.error('Build failed:', error);\n    process.exit(1);\n  }\n}\n\nrunBuild();","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}