{"id":25814958,"url":"https://github.com/ystarlongzi/fis3-hook-raw-loader","last_synced_at":"2025-10-07T02:16:25.829Z","repository":{"id":57237212,"uuid":"88865647","full_name":"ystarlongzi/fis3-hook-raw-loader","owner":"ystarlongzi","description":"A raw loader plugin for fis3.","archived":false,"fork":false,"pushed_at":"2017-04-24T13:09:48.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-24T02:22:12.459Z","etag":null,"topics":["fis3","raw-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/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}},"created_at":"2017-04-20T12:57:32.000Z","updated_at":"2017-04-23T09:23:13.000Z","dependencies_parsed_at":"2022-08-26T15:10:15.336Z","dependency_job_id":null,"html_url":"https://github.com/ystarlongzi/fis3-hook-raw-loader","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-hook-raw-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-hook-raw-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-hook-raw-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ystarlongzi%2Ffis3-hook-raw-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ystarlongzi","download_url":"https://codeload.github.com/ystarlongzi/fis3-hook-raw-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241096403,"owners_count":19908974,"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":["fis3","raw-loader"],"created_at":"2025-02-28T03:47:05.458Z","updated_at":"2025-10-07T02:16:20.802Z","avatar_url":"https://github.com/ystarlongzi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"fis3-hook-raw-loader\n====================\n\n一款基于 fis3 的 raw loader，允许在类 js 文件中嵌入其它文件的内容。\n\n\n### 安装\n```\nnpm install fis3-hook-raw-loader\n```\n\n\n### 配置\n```\nfis.hook('raw-loader');\n```\n\n\n### 用法\n```\n-- page\n  -- item.less\n  -- item.es6\n  -- item.png\n  -- list.es6\n```\n假设存在如上目录结构，其中 `item.less` 内容如下：\n```less\n.title {\n  font-size: 16px;\n\n  strong {\n    color: red;\n  }\n}\n```\n`item.es6` 内容如下：\n```javascript6\nconst word = 'Hello world!';\n```\n\n然后，我们在 `list.es6` 中可以使用以下两种方法嵌入文件内容：\n- 使用 `import` 或 `require` 关键字。（其中 `!raw!` 表示的是获取文件最初的、未做任何处理的内容）\n\n```\n// list.es6\nimport js from 'raw!./item';\nimport css from '!raw!./item.less';\nconst img = require('raw!./item.png');\n```\n\n\n- 使用 `__fis__raw()` 方法。（`!!` 和 `!raw!` 表示相同的含义）\n```\n// list.es6\nconst js = __fis__raw('!./item');\nconst css = __fis__raw('!!./item.lss');\nconst img = __fis__raw('!./item.png');\n```\n\n\n上面两种方式编译后的内容大致如下：\n```\n// list.es6\nvar js = \"var word = 'Hello world!';\";\nvar css = \".title {\\n  font-size: 16px;\\n\\n  strong {\\n    color: red;\\n  }\\n}\";\nvar img = \"data:image/png;base64,iVBORw0K......AAAElFTkSuQmCC\";\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fystarlongzi%2Ffis3-hook-raw-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fystarlongzi%2Ffis3-hook-raw-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fystarlongzi%2Ffis3-hook-raw-loader/lists"}