{"id":14973273,"url":"https://github.com/quenice/ng-extra-build","last_synced_at":"2025-04-04T16:18:46.800Z","repository":{"id":35027827,"uuid":"197566941","full_name":"quenice/ng-extra-build","owner":"quenice","description":"Extra build tool for angular-cli 1.x","archived":false,"fork":false,"pushed_at":"2022-12-09T18:49:46.000Z","size":156,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-11T04:28:39.751Z","etag":null,"topics":["angular","angular-build-tools","angular-cli","angular4"],"latest_commit_sha":null,"homepage":"","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/quenice.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":"2019-07-18T10:36:43.000Z","updated_at":"2019-07-26T09:11:25.000Z","dependencies_parsed_at":"2023-01-15T12:19:33.854Z","dependency_job_id":null,"html_url":"https://github.com/quenice/ng-extra-build","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/quenice%2Fng-extra-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quenice%2Fng-extra-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quenice%2Fng-extra-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quenice%2Fng-extra-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quenice","download_url":"https://codeload.github.com/quenice/ng-extra-build/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208307,"owners_count":20901570,"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":["angular","angular-build-tools","angular-cli","angular4"],"created_at":"2024-09-24T13:48:28.181Z","updated_at":"2025-04-04T16:18:46.784Z","avatar_url":"https://github.com/quenice.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ng-extra-build\n`ng-extra-build` is a build tool for `angular-cli`, you can use this for extra building tasks that `angular-cli` can't do, especially for *multi-environment*.\n\n\n# Getting Started\n## Installation\n```\nnpm install ng-extra-build --save-dev\n```\n\n## Usage\n### Configuration\nAfter `ng-extra-build` installation is completed, you can find a configuration file named `build.conf.json` in `$your_project_dir`, you should modify this file as your requirements. See [Configuration Reference](#configuration-reference).\n\n### Command\nSplice the following commands behind the`angular-cli` build command:\n\n```\nng-extra-build -env=envName -config=config-file-path\n```\n\nFor example, if `neware` is one of your envoriment name, add below json contents in `$Your_project_dir/package.json`:\n\n```json\n{\n  ...\n  \"scripts\": {\n    \"ng\": \"ng\",\n    \"start\": \"ng serve\",\n    \"neware\": \"ng build -prod -sm=false -aot -e neware \u0026\u0026 ng-extra-build -env=neware\"\n  },\n  ...\n}\n```\nAnd then\n\n```\nnpm run neware\n```\n\nto build application for envrionment `neware`.\n\n#### Command Arguments\n\nArgument | Required | Default | Description\n---|---|---|---\n`-env` | `true` | `null` | Envrionment name\n`-config` | `false` | `build.conf.json` | Configuration file path. The file path is relative to current working direction (same as `path.cwd()` in `nodejs`)\n\n# Features\n## Copy\nCopy files from source code to dist.\n\n**build.conf.json**\n\n```\n\"copy\": [\n  {\n    \"from\": \"$root/src/env/$env/favicon.ico\",\n    \"to\": \"$dist/favicon.ico\"\n  }\n]\n```\nIt will copy file from `$root/src/env/$env/favicon.ico` to `$dist/favicon.ico`\n\n## Compile css.\nCompile and compress `css` file from source code to dist.\n\n**build.conf.json**\n\n```\n\"css\": {\n  \"from\": \"$root/src/env/$env/css/theme.css\",\n  \"to\": \"$dist/assets/css\",\n  \"devUrl\": \"env/neware/css/theme.css\"\n}\n```\n1. Compile and compress file from `$root/src/env/$env/css/theme.css` to `$dist/assets/css`.\n2. When development mode, we can add below codes into `src/index.html`\n\n   ```\n   \u003clink rel=\"stylesheet\" href=\"env/neware/css/theme.css\"/\u003e\n   ```\n\n3. After compiled, will automatic replace `env/neware/css/theme.css` with new `href` which can link to the compied css file. You don't need do anything.\n\n## i18n\nMegre `i18n` i18n files to help you handle different `i18n` values in different environments\n\n**build.conf.json**\n\n```\n\"i18n\": {\n  \"source\": \"$root/src/assets/i18n\",\n  \"extra\": \"$root/src/env/$env/i18n\",\n  \"target\": \"$dist/assets/i18n\"\n}\n```\n\n## Replacement\nReplace content in specified file\n\n```\n\"replacement\": [\n  {\n    \"file\": \"$dist/index.html\",\n    \"contents\": [\n      {\n        \"replace\": \"Neware Club\",\n        \"with\": \"xxx\",\n        \"withEnv\": {\n          \"neware\": \"Neware RSP\",\n          \"joy\": \"Joytele RSP\"\n        }\n      }\n    ]\n  }\n],\n```\nIf `withEnv` is not null, will cover `with`.\n\n## Deletiton\nDelete files.\n\n```\n\"deletion\": [\n  \"$dist/env\"\n],\n```\n\n## Compression\nCompress directory to a single `zip` file to specified directory.\n\n```\n  \"compression\": {\n    \"from\": \"$dist\",\n    \"to\": \"$root\"\n  }\n```\n\nThe file name rule is: {`$env`}-{`package.json`.`name`}-{`package.json`.`version`}.zip.\n\nFor example, `package.json` is:\n```\n{\n  \"name\": \"euicc-portal\",\n  \"version\": \"1.0.0\",\n  \"scripts\": {\n    \"neware\": \"ng build -prod -sm=false -aot -e neware \u0026\u0026 ng-extra-build -env=neware\",\n    \"joy\": \"ng build -prod -sm=false -aot -e joy \u0026\u0026 ng-extra-build -env=joy\"\n  }\n}\n```\n\nAnd when you execute:\n\n```\nnpm run neware\n```\n\nThe `zip` file's name is : `neware-euicc-portal.1.0.0.zip`\n\n# Configuration Reference\n\n## Constants\nThere are 3 constants in `build.conf.json`\n\nName | Value\n---|---\n`$root` | Project root directory\n`$dist` | The output directory for build results.\n`$env` | Name of the envrionment currently being building. Its name is same as command argument you passed in the command line. For example, you may execute command: `ng-extra-build -env=neware`, then `$env` = `neware`\n\n\n## Configuration\n\n* **base** (`object`): The base config.\n  * *outDir* (`string`): The output directory for build results.This value must set be same as `outDir` in **Angular CLI**.\n* **copy** (`array`): Copy resources into `outDir`.\n  * *from* (`string`): Source file which will be copied.\n  * *to* (`string`): Destination file which will be copied to.\n* **css** (`object`): Css compile options.\n  * *from* (`string`): Source css file.\n  * *to* (`string`): Destination css file.\n  * *devUrl* (`string`): The css `href` in tag `\u003clink\u003e` in `index.html` for the development environment.After build, will replace this `href` with production environment `href`.\n\n* **i18n** (`object`): Build options for i18n files\n  * *source* (`string`): Directory of source i18n files\n  * *extra* (`string`): Directory of extra i18n files\n  * *target* (`string`): Directory of target i18n files\n* **replacement** (`array`): Replacement configurations\n  * *file* (`string`): The file (path) you want to execute the replacement.\n  * *contents* (`array`): Contents you want to replace.\n    * *replace* (`string`): Contents you want to replace.\n    * *with* (`string`): Contents you want to replace with\n    * *withEnv* (`object`): Contents you want to replace with for the specified environment. key is *environment name*, value is corresponding content you want to replace with.\n* **deletion** (`array`): Files you want to delete.\n* **compression** (`object`): Compression configurations.\n\n# Recommend Directory Tree\n\n```text\nsrc\n├── joy\n│   ├── css\n│   │   └── theme.css\n│   ├── favicon.ico\n│   └── i18n\n│       ├── cn.json\n│       ├── hk.json\n│       └── us.json\n└── neware\n│   ├── css\n│   │   └── theme.css\n│   ├── favicon.ico\n│   └── i18n\n│       ├── cn.json\n│       ├── hk.json\n│       └── us.json\n└── ntt\n    ├── css\n    │   └── theme.css\n    ├── favicon.ico\n    └── i18n\n        ├── cn.json\n        ├── hk.json\n        └── us.json\n    ...\n    ...\n```\n\n`neware` / `joy` / `ntt` are environments.\n\n# Example Configuration File\n\n```json\n{\n  \"$schema\": \"./node_modules/ng-extra-build/schema.json\",\n  \"base\": {\n    \"outDir\": \"dist\"\n  },\n  \"copy\": [\n    {\n      \"from\": \"$root/src/env/$env/favicon.ico\",\n      \"to\": \"$dist/favicon.ico\"\n    }\n  ],\n  \"css\": {\n    \"from\": \"$root/src/env/$env/css/theme.css\",\n    \"to\": \"$dist/assets/css\",\n    \"devUrl\": \"env/neware/css/theme.css\"\n  },\n  \"i18n\": {\n    \"source\": \"$root/src/assets/i18n\",\n    \"extra\": \"$root/src/env/$env/i18n\",\n    \"target\": \"$dist/assets/i18n\"\n  },\n  \"replacement\": [\n    {\n      \"file\": \"$dist/index.html\",\n      \"contents\": [\n        {\n          \"replace\": \"Neware Club\",\n          \"withEnv\": {\n            \"neware\": \"Neware RSP\",\n            \"joy\": \"Joytele RSP\"\n          }\n        }\n      ]\n    }\n  ],\n  \"deletion\": [\n    \"$dist/env\"\n  ],\n  \"compression\": {\n    \"from\": \"$dist\",\n    \"to\": \"$root\"\n  }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquenice%2Fng-extra-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquenice%2Fng-extra-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquenice%2Fng-extra-build/lists"}