{"id":19318296,"url":"https://github.com/feflow/replace-text-loader","last_synced_at":"2025-09-06T06:34:32.443Z","repository":{"id":57353745,"uuid":"114767741","full_name":"feflow/replace-text-loader","owner":"feflow","description":"A webpack loader for replacing content text.","archived":false,"fork":false,"pushed_at":"2018-01-15T04:22:33.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-21T15:57:45.578Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/feflow.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-12-19T13:22:24.000Z","updated_at":"2019-08-29T23:45:15.000Z","dependencies_parsed_at":"2022-09-19T02:01:18.044Z","dependency_job_id":null,"html_url":"https://github.com/feflow/replace-text-loader","commit_stats":null,"previous_names":["cpselvis/replace-text-loader"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/feflow/replace-text-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feflow%2Freplace-text-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feflow%2Freplace-text-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feflow%2Freplace-text-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feflow%2Freplace-text-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feflow","download_url":"https://codeload.github.com/feflow/replace-text-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feflow%2Freplace-text-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273867517,"owners_count":25182423,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"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":[],"created_at":"2024-11-10T01:18:04.180Z","updated_at":"2025-09-06T06:34:32.413Z","avatar_url":"https://github.com/feflow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ereplace-text-loader\u003c/h1\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm i replace-text-loader\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n**webpack.config.js**\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.index.html$/,\n        use: [{\n            loader: 'replace-text-loader',\n            options: {\n                rules: [{\n                    // inline script, 匹配所有的\u003cscript src=\"package?__inline\"\u003e\u003c/script\u003e 需要inline的标签\n                    // 并且替换为 \u003cscript\u003e${require('raw-loader!babel-loader!../../node_modules/@tencent/report-whitelist')}\u003c/script\u003e 语法\n                    pattern: /\u003cscript.*?src=\"(.*?)\\?__inline\".*?\u003e.*?\u003c\\/script\u003e/gmi,\n                    replacement: (source) =\u003e {\n                        // 找到需要 inline 的包\n                        const result = /\u003cscript.*?src=\"(.*?)\\?__inline\"/gmi.exec(source);\n                        const pkg = result \u0026\u0026 result[1];\n                        return \"\u003cscript\u003e${require('raw-loader!babel-loader!\" + pkg + \"')}\u003c/script\u003e\";\n                    }\n                }, {\n                    // inline html, 匹配\u003c!--inline[/assets/inline/meta.html]--\u003e语法\n                    pattern: /\u003c!--inline\\[.*?\\]--\u003e/gmi,\n                    replacement: (source) =\u003e {\n                        // 找到需要 inline 的包\n                        const result = /\u003c!--inline\\[(.*?)\\]--\u003e/gmi.exec(source);\n                        let path = result \u0026\u0026 result[1];\n                        if (path \u0026\u0026 path[0] === '/') {\n                            path = '../..' + path;\n                        }\n\n                        return \"${require('raw-loader!\" + path +\"')}\";\n                    }\n                }]\n            }\n        }]\n      }\n    ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeflow%2Freplace-text-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeflow%2Freplace-text-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeflow%2Freplace-text-loader/lists"}