{"id":25814968,"url":"https://github.com/ystarlongzi/fis3-preprocessor-css-modules","last_synced_at":"2026-04-18T05:32:16.334Z","repository":{"id":150313166,"uuid":"85173078","full_name":"ystarlongzi/fis3-preprocessor-css-modules","owner":"ystarlongzi","description":"基于fis3的css模块化方案","archived":false,"fork":false,"pushed_at":"2017-04-10T09:01:47.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T10:40:53.156Z","etag":null,"topics":["css-modules","fis3","loader"],"latest_commit_sha":null,"homepage":"","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/ystarlongzi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-16T08:46:47.000Z","updated_at":"2017-03-16T09:20:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8fa1076-8e39-446f-a3da-7387e814013d","html_url":"https://github.com/ystarlongzi/fis3-preprocessor-css-modules","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ystarlongzi/fis3-preprocessor-css-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-preprocessor-css-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-preprocessor-css-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-preprocessor-css-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-preprocessor-css-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ystarlongzi","download_url":"https://codeload.github.com/ystarlongzi/fis3-preprocessor-css-modules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-preprocessor-css-modules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","fis3","loader"],"created_at":"2025-02-28T03:47:06.496Z","updated_at":"2026-04-18T05:32:16.329Z","avatar_url":"https://github.com/ystarlongzi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 已废弃，请使用[fis3-hook-css-modules](https://github.com/ystarlongzi/fis3-hook-css-modules)\n\nfis3-preprocessor-css-modules\n=============================\n\n一款基于 fis3 的 [css modules](https://github.com/css-modules/css-modules) 插件。\n\n\n## 使用\n\n### 安装\n```\nnpm install fis3-preprocessor-css-module\n```\n\n### 配置\n\n1. 如果项目中有使用 `Less`、`Sass`，你还需要借助 [fis-parser-less-2.x](https://github.com/fouber/fis-parser-less-2.x)、[fis-parser-node-sass](https://github.com/fex-team/fis-parser-node-sass) 插件，将它们转换为 css 文件\n2. 你或许还需要借助 [fis3-postprocessor-postcss](https://github.com/jiangyuan/fis3-postprocessor-postcss) 插件，完成 css 属性补全等操作\n3. 此插件也具有 js-require-css 功能，所以你可能不需要在配置 [fis3-preprocessor-js-require-css](https://github.com/fex-team/fis3-preprocessor-js-require-css)\n\n\n```js\n// 将项目里的 less 文件转换为 css 文件\nfis.match('**.less', {\n    rExt: '.css',\n    parser: fis.plugin('less-2.x'),\n});\n\n// 将项目里的 sass 文件转换为 css 文件\nfis.match('**.{sass,scss}', {\n    rExt: '.css',\n    parser: fis.plugin('node-sass'),\n});\n\n// 进行 css 属性补全\nfis.match('**.{css,less,sass,scss}', {\n    postprocessor: fis.plugin('postcss'),\n});\n\n\n// ---- 配置 css modules\nfis.match('**.{js,es,es6,jsx,ts,tsx}', {\n    preprocessor: fis.plugin('css-modules'),\n});\n```\n\n\n## 参数说明\n- `mode`：加载模式，默认为 `dep`\n    * `dep`\n    简单的标记依赖，并将js语句中对应的 `require` 语句去除。fis 的资源加载程序能够分析到这块，并最终以 `\u003clink\u003e` 的方式加载 css。\n    \n    * `inline` \n    将目标 css/less/scss 文件转换成 js 语句，并直接内嵌在当前 js 中，替换原有 `require` 语句。\n    \n    * `jsRequire` \n    将目标 css 文件转换成 js 语句，但是并不内嵌，而是产出一份同名的 js 文件，当前 `require` 语句替换成指向新产生的文件。\n\n\n- `scope`：定义 class 名称生成方式。类型可为 `[function | string]`\n    * 当类型为 `function` 时，会接受三个参数\n        * `name` 待被转化的 class 名称\n        * `file` 当前文件路径\n        * `css` 当前文件内容\n        \n    ```js\n    fis.match('**.{js,es,es6,jsx,ts,tsx}', {\n        preprocessor: fis.plugin('css-modules', {\n            scope: function (name, file, css) {\n                return (file + '__' + 'name' + '__');\n            },\n        }),\n    });\n    ```\n  \n    * 当类型为 `string` 时，可以使用一些标记，如下:\n    ```js\n    fis.match('**.{js,es,es6,jsx,ts,tsx}', {\n        preprocessor: fis.plugin('css-modules', {\n            scope: '[name]__[local]___[hash:base64:5]',\n        }),\n    });\n    ```\n    你可以在[这里](https://github.com/webpack/loader-utils#interpolatename)查看这些标记的含义。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fystarlongzi%2Ffis3-preprocessor-css-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fystarlongzi%2Ffis3-preprocessor-css-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fystarlongzi%2Ffis3-preprocessor-css-modules/lists"}