{"id":21156834,"url":"https://github.com/lkiarest/html-webpack-plugin-assets-fix","last_synced_at":"2025-07-09T12:32:44.248Z","repository":{"id":57267787,"uuid":"91871725","full_name":"lkiarest/html-webpack-plugin-assets-fix","owner":"lkiarest","description":"fix assets(js/css) path in html files while building multiple entry files","archived":false,"fork":false,"pushed_at":"2018-08-31T03:34:45.000Z","size":6,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-09T21:09:55.173Z","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/lkiarest.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":"2017-05-20T07:06:18.000Z","updated_at":"2022-08-12T15:08:36.000Z","dependencies_parsed_at":"2022-09-02T05:41:03.033Z","dependency_job_id":null,"html_url":"https://github.com/lkiarest/html-webpack-plugin-assets-fix","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/lkiarest%2Fhtml-webpack-plugin-assets-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkiarest%2Fhtml-webpack-plugin-assets-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkiarest%2Fhtml-webpack-plugin-assets-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkiarest%2Fhtml-webpack-plugin-assets-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lkiarest","download_url":"https://codeload.github.com/lkiarest/html-webpack-plugin-assets-fix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225543840,"owners_count":17486063,"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-20T11:52:56.374Z","updated_at":"2024-11-20T11:52:57.355Z","avatar_url":"https://github.com/lkiarest.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# html-webpack-plugin-assets-fix\nFix html-webpack-plugin [Issue](https://github.com/jantimon/html-webpack-plugin/issues/665) that the relative assets(js/css) paths are incorrect while building multiple entries. \n\n__Before importing this plugin for sub directory resolve, please try to modify your publicPath to be relative such as '../' and check it at first.__\n\n### What's it\nWhen you wanna generate multiple entry html files via webpack and release target files within different sub directories, generally you'll config as below:\n\n```\nmodule.exports = {\n    entry: {\n        a: 'a.js',\n        b: 'b.js'\n    },\n    output: {\n        path: 'your/dist/path',\n        filename: '[name]/[name].[hash].js',\n        publicPath: ''\n    },\n    plugins: [\n        new HtmlWebpackPlugin({filename: 'a/index.html', chunks: ['a'], template: 'your/template/file/a'}),\n        new HtmlWebpackPlugin({filename: 'b/index.html', chunks: ['b'], template: 'your/template/file/b'})\n    ]\n```\n\nafter build, the dist directory seems ok:\n```\n├── dist\n│   ├── a\n│   │   ├── index.html\n│   │   └── a.xxxx.js\n│   ├── b\n│   │   ├── index.html\n│   │   └── b.xxxx.js\n```\n\nbut links of js/css files are incorrect in output html files, in 'a/index.html':\n```\n\u003cscript src='a/a.xxx.js'\u003e\u003c/script\u003e \u003c!-- wrong! --\u003e\n```\nactually it should be:\n```\n\u003cscript src='a.xxx.js'\u003e\u003c/script\u003e \u003c!-- right! --\u003e\n```\n\nThis plugin is to fix the relative path of asset files in target html file.\n\n### Usage\n\n```\nnpm i html-webpack-plugin-assets-fix -D\n\n// import this plugin in 'webpack.conf.js'\nconst HtmlWebpackPathAssetsFix = require('html-webpack-plugin-assets-fix')\n\n//...\n    plugins: [\n        new HtmlWebpackPlugin({\n            filename: 'a/index.html', \n            chunks: ['a'], \n            template: 'your/template/file/a',\n            fixAssets: true\n        }),\n        new HtmlWebpackPlugin({\n            filename: 'b/index.html', \n            chunks: ['b'], \n            template: 'your/template/file/b',\n            fixAssets: true\n        }),\n        new HtmlWebpackPathAssetsFix()\n    ]\n//...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkiarest%2Fhtml-webpack-plugin-assets-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flkiarest%2Fhtml-webpack-plugin-assets-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkiarest%2Fhtml-webpack-plugin-assets-fix/lists"}