{"id":32486325,"url":"https://github.com/fefeding/resource-load-webpack-plugin","last_synced_at":"2026-07-03T20:31:10.624Z","repository":{"id":37704119,"uuid":"493473507","full_name":"fefeding/resource-load-webpack-plugin","owner":"fefeding","description":"webpack资源加载改成ajax请求，支持js，css加载失败重试","archived":false,"fork":false,"pushed_at":"2023-11-21T06:38:58.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-12T04:59:48.792Z","etag":null,"topics":[],"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/fefeding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-05-18T01:56:10.000Z","updated_at":"2023-11-23T07:04:46.000Z","dependencies_parsed_at":"2024-05-13T04:28:47.176Z","dependency_job_id":"7ecb18bf-9b75-4bff-babd-69b72c69fd77","html_url":"https://github.com/fefeding/resource-load-webpack-plugin","commit_stats":null,"previous_names":["jiamao/jmresourceload-webpack-plugin","fefeding/resource-load-webpack-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fefeding/resource-load-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fresource-load-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fresource-load-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fresource-load-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fresource-load-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fefeding","download_url":"https://codeload.github.com/fefeding/resource-load-webpack-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fresource-load-webpack-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35101088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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":"2025-10-27T05:49:54.447Z","updated_at":"2026-07-03T20:31:10.600Z","avatar_url":"https://github.com/fefeding.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# resource-load-webpack-plugin\nwebpack4 资源加载改成ajax请求\n\n\nwebpack中的js加载默认用的是`script`标签， 本插件会把它替换成`ajax`拉取再eval。\n支持失败重载和`localStorage`缓存js\n\n\u003e 因为是ajax请求js, 如果用跨域资源，需要配置跨域头: Access-Control-Allow-Origin。\n\n# 安装\n```js\nnpm i resource-load-webpack-plugin --save-dev\n```\n\n# 使用\n\n```js\nconst jmResourceLoadPlugin = require('resource-load-webpack-plugin');\n\nplugins: [\n   new jmResourceLoadPlugin({\n        // 在页面加入全局代码 ， 比如要在index.html中加入一段全局处理逻辑或定义变量\n        globalScript: `console.log('resource-load-webpack-plugin');`,\n        // 加载完成回调，可以注入一段js，用户加载完成的一个自定义逻辑，比较上报日志等，非必须\n        // type: 'success' | 'fail' | 'timeout',   url: 资源地址, xhr： 加载资源的ajax对象或script标签       \n        // retryTime 如果指定了重试参数，这里表示当前是第几次重试，正常加载是0，后面累加\n        loadCompleteTemplate: `console.log('load:', type, url, xhr, retryTime)`,\n        // 加载前处理逻辑，可以针对加载url初始化\n        // 这里的是当加载失败时，去除域名，改为从主站获取，如果不需要请删除这里\n         // loadType: 'ajax' | 'tag' 支持ajax和script加载，可以根据条件修改这个变量 默认 ajax\n         // url  当前加载的地址\n        loadBeforeTemplate: `\n                            if(retryTime \u003e 0) url = url.replace(/^(http(s)?:)?\\\\/\\\\/[^\\\\/]+/i, '');\n                            loadType = '${process.env.NODE_ENV === 'production'?'ajax':'tag'}';\n                        `,\n        // 失败重试次数，默认2, 最大只能5次，否则采用5\n        retryTime: 2,\n        // 是否用于加载CSS\n        cssLoad: true,\n        // 脚本解析方式，开发环境下用标签tag来解析比较好调试\n        syncRunType: process.env.NODE_ENV === 'production'?'eval':'tag',\n        // 缓存url的正则, 不配置就不进行local缓存, 建议只缓存核心变化少的资源\n        // 请保证唯一性，key会当作缓存的key，比如下面示例的 chunk-common\n        // 可以在正式环境才缓存，开发环境请不要配置，不然不好调试\n        localCacheRegs: process.env.NODE_ENV === 'production'?\n        {\n            \"chunk-common.js\": /js\\/chunk-common/i,\n            \"chunk-common.css\": /css\\/chunk-common/i,\n        }: null\n    }),\n]\n```\n\n配置示例：[example](./example.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffefeding%2Fresource-load-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffefeding%2Fresource-load-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffefeding%2Fresource-load-webpack-plugin/lists"}