{"id":19699545,"url":"https://github.com/salsify/broccoli-css-modules","last_synced_at":"2025-08-03T03:10:24.025Z","repository":{"id":4062898,"uuid":"51841576","full_name":"salsify/broccoli-css-modules","owner":"salsify","description":"A broccoli plugin for compiling modular CSS","archived":false,"fork":false,"pushed_at":"2024-02-07T15:10:30.000Z","size":284,"stargazers_count":8,"open_issues_count":10,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-02T03:17:41.303Z","etag":null,"topics":["npm"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salsify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-16T14:24:33.000Z","updated_at":"2022-03-08T16:31:28.000Z","dependencies_parsed_at":"2023-01-11T16:34:37.957Z","dependency_job_id":"ff8ac015-f853-4f61-b1b8-e2ab396a548f","html_url":"https://github.com/salsify/broccoli-css-modules","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsify%2Fbroccoli-css-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsify%2Fbroccoli-css-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsify%2Fbroccoli-css-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salsify%2Fbroccoli-css-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salsify","download_url":"https://codeload.github.com/salsify/broccoli-css-modules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224175774,"owners_count":17268390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm"],"created_at":"2024-11-11T21:00:53.306Z","updated_at":"2024-11-11T21:02:07.007Z","avatar_url":"https://github.com/salsify.png","language":"JavaScript","readme":"# broccoli-css-modules [![Build Status](https://travis-ci.org/salsify/broccoli-css-modules.svg?branch=master)](https://travis-ci.org/salsify/broccoli-css-modules) [![Window Build Status](https://ci.appveyor.com/api/projects/status/github/salsify/broccoli-css-modules?svg=true)](https://ci.appveyor.com/project/dfreeman97827/broccoli-css-modules)\nA Broccoli plugin for compiling [CSS Modules](https://github.com/css-modules/css-modules).\n\n## Usage\n\nGiven a Broccoli tree containing CSS files, this plugin will emit a tree containing scoped versions of those files alongside a `.js` file for each containing a mapping of the original class names to the scoped ones.\n\n```js\nvar CSSModules = require('broccoli-css-modules');\n\nvar compiled = new CSSModules(inputCSS, {\n  // options\n});\n```\n\n## Configuration\n\nAll configuration parameters listed below are optional.\n\n##### `encoding`\nThe assumed character encoding for all files being processed. Defaults to `utf-8`.\n\n##### `extension`\nThe extension that input files will have. Defaults to `css`.\n\n##### `virtualModules`\nA hash of pre-defined modules with exported values, useful for passing in configuration to your CSS modules. For example, given this configuration:\n\n```js\nvirtualModules: {\n  'color-constants': {\n    'grass-green': '#4dbd33'\n  }\n}\n```\n\nThe following import would retrieve the value `#fdbd33`:\n\n```css\n@value grass-green from 'color-constants';\n```\n\n##### `plugins`\nAdditional [PostCSS](https://github.com/postcss/postcss) plugins that will be applied to the input styles. May be either\nan array or a hash with `before` and/or `after` keys, each containing an array of plugins.\nSpecifying only a plain array is shorthand for including those plugins in `after`.\n\n##### `generateScopedName`\nA callback to generate the scoped version of an identifier. Receives two arguments:\n - `name`: the identifier to be scoped\n - `path`: the location of the module containing the identifier\nThe function should return a string that uniquely globally identifies this name originating from the given module.\n\n##### `getJSFilePath`\nAllows for the customizing the output path for the JS file resulting from processing a CSS module. Defaults to simply replacing the extension on the input file with `.js`.\n\n##### `resolvePath`\nA callback to resolve a given import path from one file to another. Receives two arguments:\n - `importPath`: the path from which to import, as specified in the importing module\n - `fromFile`: the absolute path of the importing module\nThe function should return an absolute path where the contents of the target imported module can be located.\n\n##### `onBuildStart`\nA callback that will be invoked whenever a build or rebuild begins. Receives no arguments.\n\n##### `onBuildEnd`\nA callback that will be invoked whenever a build or rebuild concludes, whether it was successful or not. Receives no arguments.\n\n##### `onBuildSuccess`\nA callback that will be invoked whenever a build or rebuild successfully completes. Receives no arguments.\n\n##### `onBuildError`\nA callback that will be invoked whenever a build or rebuild fails with an error. Receives no arguments.\n\n##### `onProcessFile`\nA callback that will be invoked whenever a file is about to be processed. Receives one argument:\n - `path`: the path of the file about to be processed\n\n##### `formatCSS`\nA function that will be invoked to determine the output format of the namespaced CSS for a module. Receives two arguments:\n - `namespacedCSS`: a string representing the processed CSS for a given module\n - `modulePath`: the relative path of the module to be formatted\nThe function should return a string representing the content to be written out. By default, the given CSS will be emitted with a leading content indicating the path of the original module.\n\n##### `formatJS`\nA function that will be invoked to determine the output format of class name mapping for a module. Receives two arguments:\n - `classMapping`: a hash mapping each original classname from the module to its namespaced equivalent(s)\n - `modulePath`: the relative path of the module to be formatted\nThe function should return a string representing the content to be written out. By default, the given object will be emitted as the default export of an ES6 module.\n\n#### `enableSourceMaps`\nWhether inline source maps should be generated for the transformed module CSS.\n\n#### `sourceMapBaseDir`\nThe base directory relative to which paths in source maps should be encoded. Defaults to the base of the input tree.\n\n##### `postcssOptions`\nA hash of options that will be passed directly through to the PostCSS processor. This allows the use of e.g. custom syntax in the processed files.\n\n#### `onModuleResolutionFailure`\nA function that will be invoked when a referenced module cannot be found. Receives three arguments:\n - `failure`: details of why the lookup failed, if applicable\n - `modulePath`: the path specified to locate the module\n - `relativeTo`: the absolute path of the importing module\n\n#### `onImportResolutionFailure`\nA function that will be invoked when an imported symbol is not exported by the target module. Receives three arguments:\n - `symbol`: the unresolved identifier for which an import was attempted\n - `modulePath`: the path specified to locate the containing module\n - `fromFile`: the absolute path of the importing module\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalsify%2Fbroccoli-css-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalsify%2Fbroccoli-css-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalsify%2Fbroccoli-css-modules/lists"}