{"id":15420231,"url":"https://github.com/andrewbranch/no-undefined-style-loader","last_synced_at":"2025-04-06T16:51:21.426Z","repository":{"id":52079945,"uuid":"87038721","full_name":"andrewbranch/no-undefined-style-loader","owner":"andrewbranch","description":"Webpack loader that warns when an undefined key is referenced on a required CSS file","archived":false,"fork":false,"pushed_at":"2021-05-07T18:01:17.000Z","size":281,"stargazers_count":1,"open_issues_count":19,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-15T04:02:53.470Z","etag":null,"topics":["css","loader","webpack","webpack-loader"],"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/andrewbranch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-03T04:43:14.000Z","updated_at":"2018-10-03T22:10:45.000Z","dependencies_parsed_at":"2022-09-06T16:21:31.609Z","dependency_job_id":null,"html_url":"https://github.com/andrewbranch/no-undefined-style-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbranch%2Fno-undefined-style-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbranch%2Fno-undefined-style-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbranch%2Fno-undefined-style-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbranch%2Fno-undefined-style-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewbranch","download_url":"https://codeload.github.com/andrewbranch/no-undefined-style-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517942,"owners_count":20951718,"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":["css","loader","webpack","webpack-loader"],"created_at":"2024-10-01T17:28:41.625Z","updated_at":"2025-04-06T16:51:21.405Z","avatar_url":"https://github.com/andrewbranch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/no-undefined-style-loader.svg)](https://www.npmjs.com/package/no-undefined-style-loader)\n[![CircleCI](https://img.shields.io/circleci/project/github/andrewbranch/no-undefined-style-loader.svg)](https://circleci.com/gh/andrewbranch/no-undefined-style-loader)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\n# no-undefined-style-loader\n\nWebpack loader that warns when an undefined class name is referenced on a CSS file you imported into JavaScript. Works when chained after [css-loader](https://github.com/webpack-contrib/css-loader) with the [modules](https://github.com/webpack-contrib/css-loader#css-modules) option enabled.\n\nI’ve found it’s painfully easy to mistype class names (or just forget to write the CSS rule I intended to reference), and it’s not always immediately obvious what went wrong. This tool intends to catch those mistakes faster than you would by hand.\n\n**This loader is not intended to be used in production.**\n\n## Usage\n\n```js\n// webpack.config.js (Webpack 2 syntax shown)\n\nexport default {\n  entry: './app',\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: [{\n        loader: 'style-loader'\n      }, {\n        loader: 'no-undefined-style-loader',\n        options: {\n          fail: true // default: false\n        }\n      }, {\n        loader: 'css-loader',\n        options: { modules: true }\n      }\n    }]\n  }\n}\n```\n\n```css\n/* app.css */\n\n.hide {\n  display: none;\n}\n```\n\n```js\n// app.jsx\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport styles from './app.css';\n\n// This works as usual\nReactDOM.render(\n  \u003cdiv className={styles.hide} /\u003e,\n  document.getElementById('app')\n);\n\n// This results in a warning or error\nReactDOM.render(\n  \u003cdiv className={styles.thisClassNameObviouslyDoesNotExist} /\u003e,\n  document.getElementById('app')\n);\n```\n\nThe browser console will warn the developer:\n\n```\nWarning: CSS class `.thisClassNameObviouslyDoesNotExist` not found in `/Users/you/path/to/app.css`.\n```\n\n## Options\n\n- **`fail: boolean = false`** When false, accessing undefined class names warns with `console.error`. When true, attempting to access an undefined class name throws an error.\n\n## Browser support\n\nThis loader relies on [Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), which have good [support](http://caniuse.com/#search=proxy) in modern browsers. If Proxies are unavailable, the loader will emit a warning in the browser console and then do nothing.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewbranch%2Fno-undefined-style-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewbranch%2Fno-undefined-style-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewbranch%2Fno-undefined-style-loader/lists"}