{"id":13768407,"url":"https://github.com/skovhus/css-modules-flow-types","last_synced_at":"2025-04-07T17:12:23.841Z","repository":{"id":21963457,"uuid":"94547821","full_name":"skovhus/css-modules-flow-types","owner":"skovhus","description":"Creates flow type definitions from CSS Modules files using Webpack loader or CLI 👾","archived":false,"fork":false,"pushed_at":"2023-01-06T01:47:30.000Z","size":1286,"stargazers_count":93,"open_issues_count":7,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T23:55:30.027Z","etag":null,"topics":["css-modules","flow","flowtype","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skovhus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-16T13:44:00.000Z","updated_at":"2024-03-19T11:18:15.000Z","dependencies_parsed_at":"2023-01-11T21:25:43.050Z","dependency_job_id":null,"html_url":"https://github.com/skovhus/css-modules-flow-types","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fcss-modules-flow-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fcss-modules-flow-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fcss-modules-flow-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fcss-modules-flow-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skovhus","download_url":"https://codeload.github.com/skovhus/css-modules-flow-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694877,"owners_count":20980733,"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-modules","flow","flowtype","webpack","webpack-loader"],"created_at":"2024-08-03T16:01:21.057Z","updated_at":"2025-04-07T17:12:23.810Z","avatar_url":"https://github.com/skovhus.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ecss-modules-flow-types\u003c/h1\u003e\n\n  [![MIT License](https://img.shields.io/npm/l/css-modules-flow-types-loader.svg?style=flat-square)](https://github.com/skovhus/css-modules-flow-types-loader/blob/master/LICENSE)\n  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\u003c/div\u003e\n\nCLI and Webpack loader for creating [Flow](https://flow.org/) type definitions based on [CSS Modules](https://github.com/css-modules/css-modules) files.\n\nThis gives you:\n- auto-completing for css files in most editors\n- flow type safety showing usage of non existing classes\n\nRead more about the background in this blog post: [\"Type safe CSS Modules with Flow\"](https://hackernoon.com/type-safe-css-modules-with-flow-dd95e761bbe5).\n\n\n## Example\n\nGiven the following css file using CSS Modules:\n```css\n@value primary: red;\n\n.myClass {\n  color: primary;\n}\n```\n\n`css-modules-flow-types` creates the following .flow file next to it:\n\n```javascript\n// @flow\n/* This file is automatically generated by css-modules-flow-types */\ndeclare module.exports: {|\n  +'myClass': string;\n  +'primary': string;\n|};\n```\n\n\n## Usage (Webpack loader)\n\n### style-loader\nThe `css-modules-flow-types-loader` need to be added right after after `style-loader`:\n\n```sh\n$ npm install --dev css-modules-flow-types-loader\n$ yarn add -D css-modules-flow-types-loader\n```\n\n```javascript\n{\n  test: /\\.css$/,  // or the file format you are using for your CSS Modules\n  use: [\n    'style-loader',\n    'css-modules-flow-types-loader',\n    // Other loaders like css-loader after this:\n    {\n      ...\n    }\n  ]\n}\n```\n\n### css-loader\n\nFor `css-loader`, `css-modules-flow-types-loader` needs to come _before_\n`css-loader`.\n\n```javascript\n{\n  test: /\\.css$/,  // or the file format you are using for your CSS Modules\n  use: [\n    ExtractTextPlugin.extract({\n      use: [\n        'css-modules-flow-types-loader',\n        {\n          loader: 'css-loader',\n          options: {}, // Any options for css-loader\n        }\n      ]\n    })\n  ]\n}\n```\n\n## Usage (CLI)\n\n```sh\n$ npm install --dev css-modules-flow-types-cli\n$ yarn add -D css-modules-flow-types-cli\n```\n\nThis installs the runner as `css-modules-flow-types`.\n\nAnd run `css-modules-flow-types \u003cinput directory or glob\u003e` command.\n\nFor example, if you have .css files under `src` directory, exec the following:\n\nRunning,\n\n```sh\ncss-modules-flow-types src\n```\n\nCreates `*.css.flow` files next to all css files.\n\n```text\n(your project root)\n- src/\n    | myStyle.css\n    | myStyle.css.flow [created]\n```\n\n\n\n## Troubleshooting\n\n### Support for other file extensions\n\nTo support `.scss`, `.sass`, `.scss.module` or similar files extensions\nyou need to update your `.flowconfig` file with the following section:\n\n```\n[options]\n\n; Extensions\nmodule.file_ext=.js\nmodule.file_ext=.jsx\nmodule.file_ext=.json\nmodule.file_ext=.css\nmodule.file_ext=.scss\nmodule.file_ext=.sass\nmodule.file_ext=.scss.module\n// other files used by flow\n```\n\nWithout this Flow might error out with `Required module not found`.\n\n### Dynamic imports in Webpack\n\nIn some cases, attempting to load imports using dynamic references could choke webpack as it attempts to parse `.flow` files and encounters unknown syntax. The solution is to exclude `.flow` files with a `webpackExclude` directive in the import statement.\n\nIf you have an import like this:\n\n```javascript\nimport(\n  /* webpackChunkName: \"[request]\" */\n  `/Path/To/Components/${ getComponent()}`\n)\n```\n\nAdd `webpackExclude` like this:\n\n```javascript\nimport(\n  /* webpackChunkName: \"[request]\" */\n  /* webpackExclude: /\\.flow$/ */\n  `/Path/To/Components/${ getComponent()}`\n)\n```\n\n## Inspiration\n\n- https://github.com/Quramy/typed-css-modules\n- https://github.com/Jimdo/typings-for-css-modules-loader\n\n\n## Contributing\n\nTo get started, run:\n\n  yarn\n\nWhen developing:\n\n  yarn verify  # (runs lint and unit test)\n  yarn lint\n  yarn test\n  yarn test:cov\n  yarn test:watch\n\n\n## Deployment\n\nOn a new branch run:\n\n  yarn lerna version --no-git-tag-version\n  # update the CHANGELOG.md file\n  git add -p\n  git commit -m 'chore: bump version to x.x'\n\nOnce the branch is merged, the new version is deployed.\n\n## License\nThis software is released under the MIT License.\n","funding_links":[],"categories":["Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Fcss-modules-flow-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskovhus%2Fcss-modules-flow-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Fcss-modules-flow-types/lists"}