{"id":13806738,"url":"https://github.com/smartin85/ng-cli-hooks","last_synced_at":"2025-10-26T12:48:34.680Z","repository":{"id":32956066,"uuid":"147697886","full_name":"smartin85/ng-cli-hooks","owner":"smartin85","description":"Hooks for the angular-cli","archived":false,"fork":false,"pushed_at":"2023-10-19T09:12:57.000Z","size":1763,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-18T05:21:08.062Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/smartin85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["smartin85"],"custom":["https://www.buymeacoffee.com/smartin"]}},"created_at":"2018-09-06T15:53:44.000Z","updated_at":"2022-01-27T18:09:08.000Z","dependencies_parsed_at":"2024-06-03T13:48:22.179Z","dependency_job_id":"88b0b0ba-0b6d-4ebd-8eea-2502da8d1e23","html_url":"https://github.com/smartin85/ng-cli-hooks","commit_stats":{"total_commits":41,"total_committers":5,"mean_commits":8.2,"dds":0.5121951219512195,"last_synced_commit":"78d503cec5cd73fda19aaf15d94e1154d6522cc1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/smartin85/ng-cli-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fng-cli-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fng-cli-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fng-cli-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fng-cli-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartin85","download_url":"https://codeload.github.com/smartin85/ng-cli-hooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fng-cli-hooks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270077928,"owners_count":24523293,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-04T01:01:15.475Z","updated_at":"2025-10-26T12:48:34.582Z","avatar_url":"https://github.com/smartin85.png","language":"TypeScript","funding_links":["https://github.com/sponsors/smartin85","https://www.buymeacoffee.com/smartin"],"categories":["Table of contents"],"sub_categories":["Angular"],"readme":"# ng-cli-hooks\n[![MIT License][license-image]][license-url] \n[![npm version][npm-image]][npm-url]\n[![npm downloads][downloads-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n\n[![Buy me a coffee][buy-me-a-coffee-image]][buy-me-a-coffee-url]\n\nHooks for the angular-cli\n\n\u003e Unfortunately I don't have much time to take care of this project, so please contribute when new versions of Angular are released.\n\u003e As an alternative to this package, I recommend taking a look at the [angular-builders](https://github.com/just-jeb/angular-builders) repo. They are much faster when new Angular versions are released.\n\n## This documentation is for version 16 only\nDocumentation for other versions could be found here:\n- [Version 15.x.x](https://github.com/smartin85/ng-cli-hooks/blob/15.0.0/README.md)\n- [Version 13.x.x](https://github.com/smartin85/ng-cli-hooks/blob/13.0.0/README.md)\n- [Version 11.x.x](https://github.com/smartin85/ng-cli-hooks/blob/11.0.0/README.md)\n- [Version 8.x.x](https://github.com/smartin85/ng-cli-hooks/blob/8.0.0/README.md)\n- [Version 7.x.x](https://github.com/smartin85/ng-cli-hooks/blob/7.0.0/README.md)\n\n## Getting Started\nInstall the package:\n```\nnpm install --save-dev ng-cli-hooks\n```\n\nUpdate your `angular.json` file:\n\n```json\n{\n  ...\n  \"projects\": {\n    \"app\": {\n      ...\n      \"architect\": {\n        \"build\": {\n          \"builder\": \"ng-cli-hooks:browser\",\n          \"options\": {\n            \"optionsHook\": \"hooks/options.js\",\n            \"webpackHook\": \"hooks/webpack.js\",\n            \"indexHtmlHook\": \"hooks/index-html.js\",\n            ...\n```\n\nThis Plugin contains hookable builders for\n- browser\n- dev-server\n- server\n\n## Hooks\nCurrently this plugin contains three different hooks: `optionsHook`, `webpackHook` and `indexHtmlHook`.\n\n### optionsHook\nThis hook modifies the options for the builder at build-time.\n\nExample: `hooks/options.js`\n```javascript\nmodule.exports = function (options) {\n    if (process.env.APP_BRANDING) {\n        var branding = process.env.APP_BRANDING.trim();\n        if (options.assets) {\n            options.assets = options.assets.map(asset =\u003e {\n                if (asset.input === 'src/assets') {\n                    asset.input = `src/branding/${branding}/assets`;\n                }\n                return asset;\n            });\n        }\n    }\n\n    return options;\n}\n```\n\n### indexHtmlHook\nThis hook modifies the generated index.html at build-time.\nIt is only available for the builders `browser` and `dev-server`.\n\nExample: `hooks/index-html.js`\n```javascript\nmodule.exports = function(content, options) {\n    content = content.replace('Ionic App', 'Example App');\n    return content;\n}\n```\n\n### webpackHook\nThis hook can be used to modify the generated webpack-config of angular-cli or to replace it.\n\n#### Modify the generated webpack-config\nDuring the development of this hook it may be necessary to clear the Angular cache.\n\nExample: `hooks/webpack.js`\n```javascript\nfunction replaceAngularCompilerPlugin(plugins) {\n  const plugin = plugins.find(p =\u003e p.pluginOptions \u0026\u0026 p.pluginOptions.directTemplateLoading);\n  const options = plugin.pluginOptions;\n  options.directTemplateLoading = false;\n}\n\nmodule.exports = function (generatedWebpackConfig, options) {  \n  generatedWebpackConfig.module.rules.unshift({\n    test: /\\.html$/,\n    loader: 'string-replace-loader',\n    options: {\n        search: /Welcome/ig,\n        replace: () =\u003e 'Welcome to ng-cli-hooks',\n        flags: 'g'\n    }\n  });\n\n  replaceAngularCompilerPlugin(generatedWebpackConfig.plugins);\n\n  return generatedWebpackConfig;\n}\n```\n\n#### Replace the generated webpack-config\nIf `hooks/webpack.js` exports a webpack-config-object, than the generated webpack-config will be replaced by your own.\n\n## Changelog\n### 16.0.0\n- Support for Angular 16\n### 15.0.0\n- Support for Angular 15\n### 13.0.0\n- Support for Angular 13\n### 12.0.0\n- Support for Angular 12\n### 11.0.0\n- Support for Angular 11\n### 8.0.0\n- Support for Angular 8\n- Removed builders for `extract-i18n` and `cordova-build`\n- Added `indexHtmlHook` to hook into the index.html build.\n\n### 7.0.0\n- Major version of ng-cli-hooks now equals the Angular version (use ng-cli-hooks@7.x.x to work with Angular 7.x.x)\n\n### 1.1.0\n- added `ng-cli-hooks:cordova-build` for Ionic 4 projects.\n\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n[license-url]: LICENSE\n\n[npm-image]: https://badge.fury.io/js/ng-cli-hooks.svg\n[npm-url]: https://www.npmjs.com/package/ng-cli-hooks\n\n[downloads-image]: https://img.shields.io/npm/dt/ng-cli-hooks.svg\n\n[snyk-image]: https://snyk.io/test/github/smartin85/ng-cli-hooks/badge.svg\n[snyk-url]: https://snyk.io/test/github/smartin85/ng-cli-hooks\n\n[buy-me-a-coffee-image]: https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png\n[buy-me-a-coffee-url]: https://www.buymeacoffee.com/smartin","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartin85%2Fng-cli-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartin85%2Fng-cli-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartin85%2Fng-cli-hooks/lists"}