{"id":22962796,"url":"https://github.com/asiareal/html-anywhere-webpack-plugin","last_synced_at":"2025-04-02T03:29:09.340Z","repository":{"id":57267292,"uuid":"123783076","full_name":"asiareal/html-anywhere-webpack-plugin","owner":"asiareal","description":"通过设置标记，可以将生成的js\u0026css文件，插入到html文件的任何一个地方","archived":false,"fork":false,"pushed_at":"2018-03-04T11:50:31.000Z","size":2,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T05:03:01.444Z","etag":null,"topics":["html-webpack-plugin","webpack","webpack-plugin"],"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/asiareal.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":"2018-03-04T11:42:24.000Z","updated_at":"2019-06-01T02:48:00.000Z","dependencies_parsed_at":"2022-08-26T13:41:09.020Z","dependency_job_id":null,"html_url":"https://github.com/asiareal/html-anywhere-webpack-plugin","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/asiareal%2Fhtml-anywhere-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asiareal%2Fhtml-anywhere-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asiareal%2Fhtml-anywhere-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asiareal%2Fhtml-anywhere-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asiareal","download_url":"https://codeload.github.com/asiareal/html-anywhere-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246749719,"owners_count":20827579,"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":["html-webpack-plugin","webpack","webpack-plugin"],"created_at":"2024-12-14T19:18:22.131Z","updated_at":"2025-04-02T03:29:09.309Z","avatar_url":"https://github.com/asiareal.png","language":"JavaScript","readme":"# html-anywhere-webpack-plugin\n\n通过设置标记，可以将webpack打包生成的js\u0026css文件，插入到html文件的任何一个地方\n\n`html-webpack-plugin` inject 属性只支持在`head` 和 `body`插入js 和 css 标签。有时候我们更想在我们规定的地方插入对应的标签。`html-anywhere-webpack-plugin`就是帮你解决这个问题的，简单方便。\n\n## 标记\n类型 | 标记\n---- | ----\njs | `\u003c!--{JS_INJECT_POSITION}--\u003e`\ncss | `\u003c!--{CSS_INJECT_POSITION}--\u003e`\n\n## 使用\n`npm install html-anywhere-webpack-plugin --save-dev`\n\n在配置文件中引入\n\n```js\nvar HtmlWebpackPlugin = require('html-webpack-plugin')\nvar HtmlAnywhereWebpackPlugin = require('html-anywhere-webpack-plugin')\n\n...\n  plugins:[\n    ...\n    new HtmlWebpackPlugin({\n      ...\n      inject: false\n    }),\n    new HtmlAnywhereWebpackPlugin()\n  ]\n```\n\n然后就可以在html文件的任何一个地方添加标记了，例如：\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"\u003e\n  \u003ctitle\u003etitle\u003c/title\u003e\n  \u003c!-- 需要添加这段代码，将打包的css渲染到此处 --\u003e\n  \u003c!--{CSS_INJECT_POSITION}--\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003ehello single page\u003c/h1\u003e\n  \u003c!-- 需要添加这段代码，将打包的js渲染到此处 --\u003e\n  \u003c!--{JS_INJECT_POSITION}--\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasiareal%2Fhtml-anywhere-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasiareal%2Fhtml-anywhere-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasiareal%2Fhtml-anywhere-webpack-plugin/lists"}