angular app config file in the root build folder

Discussão em 'Angular' iniciado por Heybat, Outubro 30, 2024.

  1. Heybat

    Heybat Guest

    I need to implement an app config folder that will be loaded when the app is initialized (APP_INITIALIZER) (example is in https://devblogs.microsoft.com/premier-developer/angular-how-to-editable-config-files/). the issue is when you have localization enabled you have several folders (en, az, ru) when the app is built and in every folder, you have a configs folder. you need to change configs in every folder and it is very hard to keep them in sync. Do you have a solution for this issue?

    dist/faq
    --en
    --configs
    --assets
    --ru
    --configs
    --assets
    --az
    --configs
    --assets


    i need this structure

    dist/faq
    --configs
    --en
    --assets
    --ru
    --assets
    --az
    --assets


    angular.json

    {
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
    "faq": {
    "root": "",
    "sourceRoot": "src",
    "projectType": "application",
    "prefix": "app",
    "schematics": {},
    "architect": {
    "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
    "localize": true,
    "outputPath": "dist/faq",
    "index": "src/index.html",
    "main": "src/main.ts",
    "polyfills": "src/polyfills.ts",
    "tsConfig": "src/tsconfig.app.json",
    "assets": [
    "src/favicon.ico",
    "src/assets",
    {
    "glob": "**/*",
    "input": "src/assets/js/service-worker/",
    "output": "/"
    },
    {
    "glob": "app-configuration.json",
    "input": "src/configs/",
    "output": "configs/"
    }
    ],
    "styles": [
    "src/styles.scss",
    "src/global-scss/table-style.scss",
    "src/global-scss/theme-1.scss",
    "src/global-scss/theme-2.scss",
    "src/global-scss/theme-3.scss",
    "src/global-scss/theme-4.scss"
    ],
    "scripts": [],
    "vendorChunk": true,
    "extractLicenses": false,
    "buildOptimizer": false,
    "sourceMap": true,
    "optimization": false,
    "namedChunks": true
    },
    "configurations": {
    "production": {
    "localize": ["ru", "az"],
    "budgets": [
    {
    "type": "anyComponentStyle",
    "maximumWarning": "6kb"
    }
    ],
    "fileReplacements": [
    {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.prod.ts"
    }
    ],
    "optimization": true,
    "outputHashing": "all",
    "sourceMap": false,
    "namedChunks": false,
    "extractLicenses": true,
    "vendorChunk": false,
    "buildOptimizer": true
    },
    "ru": {
    "localize": ["ru"]
    },
    "az": {
    "localize": ["az"]
    }
    },
    "defaultConfiguration": ""
    },
    "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
    "browserTarget": "faq:build"
    },
    "configurations": {
    "production": {
    "browserTarget": "faq:build:production"
    },
    "ru": {
    "browserTarget": "faq:build:ru"
    },
    "az": {
    "browserTarget": "faq:build:az"
    }
    }
    },
    "extract-i18n": {
    "builder": "@angular-devkit/build-angular:extract-i18n",
    "options": {
    "browserTarget": "faq:build"
    }
    },
    "test": {
    "builder": "@angular-devkit/build-angular:karma",
    "options": {
    "main": "src/test.ts",
    "polyfills": "src/polyfills.ts",
    "tsConfig": "src/tsconfig.spec.json",
    "karmaConfig": "src/karma.conf.js",
    "styles": ["src/styles.scss", "src/themes.scss"],
    "scripts": [],
    "assets": ["src/favicon.ico", "src/assets"]
    }
    }
    },
    "i18n": {
    "sourceLocale": "en",
    "locales": {
    "ru": {
    "baseHref": "ru/",
    "translation": "src/locales/messages.ru.xlf"
    },
    "az": {
    "baseHref": "az/",
    "translation": "src/locales/messages.az.xlf"
    }
    }
    }
    },
    "faq-e2e": {
    "root": "e2e/",
    "projectType": "application",
    "architect": {
    "e2e": {
    "builder": "@angular-devkit/build-angular:protractor",
    "options": {
    "protractorConfig": "e2e/protractor.conf.js",
    "devServerTarget": "faq:serve"
    },
    "configurations": {
    "production": {
    "devServerTarget": "faq:serve:production"
    }
    }
    }
    }
    }
    },
    "schematics": {
    "@schematics/angular:component": {
    "style": "scss"
    }
    },
    "cli": {
    "analytics": "5cb03c1f-c147-4fbb-977b-2a3f3c5936a8"
    }
    }

    Continue reading...

Compartilhe esta Página