{"id":21937410,"url":"https://github.com/packingjs/replace-hash-webpack-plugin","last_synced_at":"2025-04-22T12:07:59.429Z","repository":{"id":57353692,"uuid":"58514158","full_name":"packingjs/replace-hash-webpack-plugin","owner":"packingjs","description":"This is a webpack plugin that update script references in HTML files by webpack bundle's hash.","archived":false,"fork":false,"pushed_at":"2018-01-26T06:43:03.000Z","size":19,"stargazers_count":6,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T12:07:25.574Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/packingjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-11T04:25:42.000Z","updated_at":"2022-09-15T10:40:25.000Z","dependencies_parsed_at":"2022-09-16T08:20:57.236Z","dependency_job_id":null,"html_url":"https://github.com/packingjs/replace-hash-webpack-plugin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Freplace-hash-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Freplace-hash-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Freplace-hash-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/packingjs%2Freplace-hash-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/packingjs","download_url":"https://codeload.github.com/packingjs/replace-hash-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237832,"owners_count":21397401,"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-29T01:19:42.794Z","updated_at":"2025-04-22T12:07:59.370Z","avatar_url":"https://github.com/packingjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Replace Hash Webpack plugin\n\n[![NPM](https://nodei.co/npm/replace-hash-webpack-plugin.png)](https://nodei.co/npm/replace-hash-webpack-plugin/)\n\nThis is a [webpack](http://webpack.github.io/) plugin that update script references in HTML files by webpack bundle's hash.\n\n It uses the [glob](https://github.com/isaacs/node-glob) library to do files matching.\n\n## Installation\n\nInstall the plugin with npm:\n```shell\n$ npm install replace-hash-webpack-plugin --save-dev\n```\n\n## Configuration\n\nYou can pass a hash of configuration options to `ReplaceHashWebpackPlugin`.\nAllowed values are as follows:\n\n- `cwd`: The current work directory.\n- `src`: The original pattern the minimatch object represents.\n- `dest`: Dest files save path.\n- `pattern`: {Array} (optional) Find and replace rules.\n- `exts`: {Array} (optional) Asset types to be replaced. Default: ['js', 'css']\n\n## Example\n\n```javascript\n//webpack.config.js\nvar ReplaceHashWebpackPlugin = require('replace-hash-webpack-plugin');\nvar webpackConfig = {\n  entry: 'main.js',\n  output: {\n    filename: '[name]-[hash:8].js',\n    publicPath: 'http://www.cdn.com/js/',\n  },\n  plugins: [\n    new ReplaceHashWebpackPlugin({\n      cwd: 'static',\n      src: '**/*.jade',\n      dest: 'prd',\n    }),\n    // new ReplaceHashWebpackPlugin({\n    //   cwd: process.cwd() + '/static',\n    //   src: '**/*.html',\n    //   dest: process.cwd() + '/prd',\n    //   exts: ['png', 'jpg', 'jpeg'],\n    //   pattern: [\n    //     {\n    //       find: '([\\'\"])([/]?%s)([\"\\'])',\n    //       replace: '$1%s$3'\n    //     }\n    //   ]\n    // }),\n  ]\n};\n```\n\n```html\n\u003c!-- static/index.html --\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003ctitle\u003ereplace-hash-webpack-plugin\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cscript src=\"/js/main.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### result:\n\n```html\n\u003c!-- prd/index.html --\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003ctitle\u003ereplace-hash-webpack-plugin\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cscript src=\"http://www.cdn.com/js/main-e8f4f5aa.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpackingjs%2Freplace-hash-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpackingjs%2Freplace-hash-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpackingjs%2Freplace-hash-webpack-plugin/lists"}