I would like to have two versions of my Application with the same codebase. One Version should for example include the "registration" feature and the other one not. Can I configure Angular somehow that an env file determines what gets excluded during compilation? Or does the compiler anyway remove unreachable code. For example, if I have two feature.json files and each build process gets one of them. And in my code I just check if the feature is activated in my feature.json
Can I exclude features (routes, components...) in my Angular application during Build time depending on a env file?
1k views Asked by user3241778 At
1
There are 1 answers
Related Questions in ANGULAR
- Firebase link existing user to anonymous account?
- It doesnt always show all the books on my homepage
- Google adsense ads.txt status cannot be not found
- When I navigate to the URL'http://localhost:4200/', it redirects me back
- Ionic Angular Standalone ion-icon are not showing at all
- How to make Angular understand that view child is of a specific type, not a general ElementRef?
- vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Ngrx props<>() method in createAction()
- How to animate rotation of an image inside input control?
- Detecting click inside and outside of the listening component in Angular
- Angular - type guard not narrowing types
- In node_modules file i am getting Angular genric error while using fontawesome in angular12
- Angular 16 sending null values to API
- GoogleCloud Error: Not Found The requested URL was not found on this server
Related Questions in ANGULAR-IVY
- Dynamic Angular component with template from string
- Getting Field 'browser' doesn't contain a valid alias configuration
- Sharing Angular Modules with Ivy Compilation Requirement Between Two Projects
- Loading Component Template from Database or File
- After upgrading my application from Angular 14 to 16, I am getting 100's of errors in npm packages that I have used
- Fix errors to upgrade old module for Angular 16
- Using @ag-grid-community/angular version <28 with Angular 16
- angular 15 truely dynamic components with compileModuleAndAllComponentsAsync
- I cannot use component inside the same library in Angular
- Angular component not rendering when passed as a string in a innerHtml attribute
- Angular 13 Update "Duplicate identifier" Error
- Can I exclude features (routes, components...) in my Angular application during Build time depending on a env file?
- Angular components loaded from different module not rendered in dynamic compiled component
- Angular "partial" vs "full" compilation mode?
- It looks like '' has not been IVY compiled - it has no 'ɵcmp' field
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Yes, angular has this built in. There are already two different compilation versions by default: production and development. You can add more. The environment objects are found in the
environmentsdirectory. The build configurations are inangular.json. When building you use the commandng build --configuration=myConfigurationName.Here's the docs: https://angular.io/guide/build
Here's the default configurations:
Notice how in production, the
environment.tsfile gets replaced by theenvironment.prod.tsfile.So you have two options:
You can create two new environment files and use boolean feature toggles to include and exclude functionality. So you import the object from
environment.ts, but you replace that environment file during compilation. The issue is anyone can still activate that functionality using the debugger.You can have two versions of specific files and replace those files depending on what version you want. The downside is it'll be extra work to keep common functionality synced between versions. Anything that is not common will need to be in separate files.