{"id":18484158,"url":"https://github.com/jdf2e/jdf-env-switch","last_synced_at":"2025-05-13T21:13:08.108Z","repository":{"id":57147556,"uuid":"99985556","full_name":"jdf2e/jdf-env-switch","owner":"jdf2e","description":"【jdf插件】切换生产环境和开发环境","archived":false,"fork":false,"pushed_at":"2017-08-11T07:06:48.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T21:37:31.127Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdf2e.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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-08-11T02:57:18.000Z","updated_at":"2017-09-30T11:03:16.000Z","dependencies_parsed_at":"2022-09-06T14:51:42.257Z","dependency_job_id":null,"html_url":"https://github.com/jdf2e/jdf-env-switch","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/jdf2e%2Fjdf-env-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-env-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-env-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-env-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdf2e","download_url":"https://codeload.github.com/jdf2e/jdf-env-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029008,"owners_count":22002284,"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-06T12:38:46.994Z","updated_at":"2025-05-13T21:13:03.097Z","avatar_url":"https://github.com/jdf2e.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jdf环境切换插件\n是否烦恼在交付后端时需要切换url？是否烦恼html中引用的img标签本地开发和线上路径不一致？\n\n环境切换插件帮你在`jdf output`时不再手动切换这些配置，一条命令，直接交付\n\n## 语法示例\n```\n{%env-dev \nwindow.location.href = '/html/print.html';\nenv%}\n{%env-prod\nwindow.location.href = '/manage/print';    \nenv%}  \n```\n\n## 配置项\n`config.json`的plugin属性里提供三个配置项:\n\ntags指明工程中使用那些标签: `{%env-tag code here env%}`.\n\nbuildTag配置在`jdf build`阶段使用哪个tag\n\noutputTag配置在`jdf output`阶段使用哪个tag\n\n### 注意点\n每个tag代表一个编译环境，因此所有tag都是互斥的，编译其中一个tag，其他tag里的内容将会清空\n\n\n```\n{\n\"name\": \"jdf-env-switch\",\n\"tags\": [\"dev\", \"prod\", \"dev1\"],\n\"buildTag\": \"dev\",\n\"outputTag\": \"prod\"\n}\n```\n\n## 支持环境切换的文件\n* html, htm, xhtml\n* vm, smarty, tpl, jade,\n* js, babel, es6\n* json, yml\n\n## 真实示例\n* 切换html、vm、smarty文件里的url路径\n``` html\n手动切换：\n\u003cdiv class=\"talent-nav\"\u003e\u003ca href=\"/html/search-result.html?type=deptCard\"\u003e部门人才简历\u003c/a\u003e\u003c/div\u003e\n\u003c!-- \u003cdiv class=\"talent-nav\"\u003e\u003ca href=\"/manage/search-result?type=deptCard\"\u003e部门人才简历\u003c/a\u003e\u003c/div\u003e --\u003e\n\n自动编译：\n{%env-dev\n\u003cdiv class=\"talent-nav\"\u003e\u003ca href=\"/html/search-result.html?type=deptCard\"\u003e部门人才简历\u003c/a\u003e\u003c/div\u003e\nenv%}\n{%env-prod\n \u003cdiv class=\"talent-nav\"\u003e\u003ca href=\"/manage/search-result?type=deptCard\"\u003e部门人才简历\u003c/a\u003e\u003c/div\u003e \nenv%}\n```\n\n* 切换js文件里的路径\n``` js\n手动切换：\nwindow.location.href = '/html/print.html';\n// window.location.href = '/manage/print';   \n\n自动编译：\n{%env-dev \nwindow.location.href = '/html/print.html';\nenv%}\n{%env-prod\nwindow.location.href = '/manage/print';    \nenv%}  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-env-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdf2e%2Fjdf-env-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-env-switch/lists"}