{"id":20542181,"url":"https://github.com/weivea/gulp-html-helper","last_synced_at":"2025-04-14T09:13:09.132Z","repository":{"id":57257767,"uuid":"56823013","full_name":"weivea/gulp-html-helper","owner":"weivea","description":"对html引用静态资源做处理的gulp插件","archived":false,"fork":false,"pushed_at":"2016-05-26T12:30:29.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T09:12:33.005Z","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/weivea.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}},"created_at":"2016-04-22T03:17:11.000Z","updated_at":"2022-09-26T08:15:19.000Z","dependencies_parsed_at":"2022-08-25T21:22:46.162Z","dependency_job_id":null,"html_url":"https://github.com/weivea/gulp-html-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fgulp-html-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fgulp-html-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fgulp-html-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fgulp-html-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weivea","download_url":"https://codeload.github.com/weivea/gulp-html-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852182,"owners_count":21171842,"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":[],"created_at":"2024-11-16T01:29:39.658Z","updated_at":"2025-04-14T09:13:09.080Z","avatar_url":"https://github.com/weivea.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-html-helper\n\n## Install\n\n`npm install --save-dev gulp-html-helper `\n\n## Usage\n\n**ps:htmlHelper只处理相对路径的引用连接**\n\n```\nvar gulp = require('gulp');\nvar htmlHelper = require('gulp-html-helper');\n\nvar option = {\n    staticPath: '_devTmp/static',\n    urlBasePath: 'static/',\n    aliasPath: {'originalPath':'aliasPath'},\n    md5:true\n}\n\ngulp.task('default', function () {\n    return gulp.src('src/*.html')\n        .pipe(htmlHelper(option))\n        .pipe(gulp.dest('dist'));\n});\n\n```\n\n## Option\n\n- staticPath: html里面引用的静态资源被输出的目的目录（必填项）\n- urlBasePath:html里面引用的静态资源链接的公共路径（默认为'/'）\n- aliasPath:处理前,将HTML里面的静态资源引用链接做指定替换处理,遇到链接中有「originalPath」则先替换为「aliasPath」（不设置,则不做替换处理）\n- rootPathIMG:图片资源跟路径,要求以相对路径格式书写(默认为程序运行路径)\n- rootPathCSS:CSS资源跟路径,要求以相对路径格式书写(默认为程序运行路径)\n- rootPathJS:JS资源跟路径,要求以相对路径格式书写(默认为程序运行路径)\n\n\n- md5:处理链接时,是否加上md5\n\n## Example\n\n\n\noption配置如下\n\n```\nvar option = {\n    staticPath: '_devTmp/static',\n    urlBasePath: 'static/',\n    aliasPath: {'originalPath':'aliasPath'},\n    md5:true\n}\n```\n\n处理前的html\n\n```\n\u003c!doctype html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"/\u003e\n    \u003cmeta http-equiv=\"x-ua-compatible\" content=\"ie=edge\"/\u003e\n    \u003ctitle\u003ereact-babel\u003c/title\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/\u003e\n    \u003clink href=\"../cssStyle/aa.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=\"app\"\u003e\u003c/div\u003e\n\n\u003ca href=\"/a/s\"\u003e\u003c/a\u003e\n\u003cimg src=\"../img/pic20160106.jpg\"\u003e\n\u003cscript src=\"https://static.qbox.me/webClint/jsPlugins/plugins/for_react_babel/react-with-addons.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://static.qbox.me/webClint/jsPlugins/plugins/for_react_babel/react-dom.min.js\"\u003e\u003c/script\u003e\n\n\n\n\u003cscript src=\"/jsEntries/index.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"../jsEntries/index.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n处理后的html\n\n```\n\u003c!doctype html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"/\u003e\n    \u003cmeta http-equiv=\"x-ua-compatible\" content=\"ie=edge\"/\u003e\n    \u003ctitle\u003ereact-babel\u003c/title\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/\u003e\n    \u003clink href=\"static/aa-d555e48d71746b90d810522ae7445f45.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=\"app\"\u003e\u003c/div\u003e\n\n\u003ca href=\"/a/s\"\u003e\u003c/a\u003e\n\u003cimg src=\"static/5df5003623c86ad78e83fb55f825f008.jpg\"\u003e\n\u003cscript src=\"https://static.qbox.me/webClint/jsPlugins/plugins/for_react_babel/react-with-addons.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://static.qbox.me/webClint/jsPlugins/plugins/for_react_babel/react-dom.min.js\"\u003e\u003c/script\u003e\n\n\n\n\u003cscript src=\"/jsEntries/index.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"static/index-596eb908f90deafc0ab196444e478eb1.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nstaticPath指定Path:_devTmp/static下的静态文件\n- 5df5003623c86ad78e83fb55f825f008.jpg\n- aa-d555e48d71746b90d810522ae7445f45.css\n- index-596eb908f90deafc0ab196444e478eb1.js\n\n\n##Todo\n\n小的图片直接base64\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweivea%2Fgulp-html-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweivea%2Fgulp-html-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweivea%2Fgulp-html-helper/lists"}