{"id":15061031,"url":"https://github.com/phasereditor2d/phaser-asset-pack-hashing","last_synced_at":"2025-04-14T05:42:34.955Z","repository":{"id":57322837,"uuid":"382218358","full_name":"PhaserEditor2D/phaser-asset-pack-hashing","owner":"PhaserEditor2D","description":"A script for hashing the Phaser Asset Pack files","archived":false,"fork":false,"pushed_at":"2023-09-13T15:00:14.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T21:05:12.843Z","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/PhaserEditor2D.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-02T03:21:06.000Z","updated_at":"2024-12-05T15:47:34.000Z","dependencies_parsed_at":"2025-01-21T22:40:00.437Z","dependency_job_id":null,"html_url":"https://github.com/PhaserEditor2D/phaser-asset-pack-hashing","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphaser-asset-pack-hashing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphaser-asset-pack-hashing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphaser-asset-pack-hashing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphaser-asset-pack-hashing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhaserEditor2D","download_url":"https://codeload.github.com/PhaserEditor2D/phaser-asset-pack-hashing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830420,"owners_count":21168272,"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-09-24T23:08:28.766Z","updated_at":"2025-04-14T05:42:34.924Z","avatar_url":"https://github.com/PhaserEditor2D.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phaser Asset Pack Hashing\n\nA script for hashing the Phaser Asset Pack files, making them ready for production.\n\nThe Asset Pack Files are a key part of [Phaser Editor 2D](https://phasereditor2d.com).\n\n## Motivation\n\nIt is common that build tools like Webpack generate production files that include the content hash in the file name.\nThe `phaser-asset-pack-hashing` script allows changing the Phaser Asset Pack files internal URLs for including the file hash.\n\nFor example, if yo have an Asset Pack File like this:\n\n```json\n{\n    \"section1\": {\n        \"files\":[\n            {\n                \"type\": \"image\",\n                \"key\": \"background\",\n                \"url\": \"assets/background.png\"\n            }\n        ]\n    }\n}\n```\n\nThe script modifies it changing the URL of the `background` image:\n\n```json\n{\n    \"section1\": {\n        \"files\":[\n            {\n                \"type\": \"image\",\n                \"key\": \"background\",\n                \"url\": \"assets/background.png?h=226313014646669c2ee7\"\n            }\n        ]\n    }\n}\n```\n\nNote it adds a query string `h=226313014646669c2ee7`.\n\nAdditionally, you can process all JavaScript files and replace the URL of the Asset Pack files for an URL with a hash:\n\nThe code:\n\n```js\nthis.load.pack(\"preloader\", \"assets/preloader-pack.json\")\n```\n\nChanges to:\n\n```js\nthis.load.pack(\"preloader\", \"assets/preloader-pack.json?h=7e8b50fa0c74d225fbee\")\n```\n\n## Usage\n\nInstall:\n\n```bash\nnpm install -g phaser-asset-pack-hashing\n```\n\nRun the script with the `--root` (alias `-r`) option (required):\n\n```bash\n$ phaser-asset-pack-hashing -r path/to/game/dist/\n```\n\nIt scans the `path/to/game/dist` folder for Asset Pack files and modify them.\n\nIt is important to highlight that this tool should be applied to the distribution build of your game. You should not modify the Pack Files of your working sources.\n\nFor enabling the replacement of the Asset Pack files URL in the JavaScript code, use the `--js` (alias `-j`) option:\n\n```bash\n$ phaser-asset-pack-hashing -j -r path/to/game/dist/\n```\nIt is possible that you don't need to process the JavaScript files. You can use your build tool for importing static assets like the Asset Pack files.\n\nYou can see all options:\n\n```bash\n$ phaser-asset-pack-hashing -h\n```\n\n## TODO\n\n* Write a tutorial about using this tool and Webpack.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fphaser-asset-pack-hashing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphasereditor2d%2Fphaser-asset-pack-hashing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fphaser-asset-pack-hashing/lists"}