mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
afford production disable preboot
This commit is contained in:
19
README.md
19
README.md
@@ -101,7 +101,7 @@ Installing
|
|||||||
|
|
||||||
### Configuring
|
### Configuring
|
||||||
|
|
||||||
Default configuration file is located in `config/` folder.
|
Default runtime configuration file is located in `config/` folder. These configurations can be changed without rebuilding the distribution.
|
||||||
|
|
||||||
To override the default configuration values, create local files that override the parameters you need to change. You can use `config.example.yml` as a starting point.
|
To override the default configuration values, create local files that override the parameters you need to change. You can use `config.example.yml` as a starting point.
|
||||||
|
|
||||||
@@ -167,6 +167,22 @@ These configuration sources are collected **at run time**, and written to `dist/
|
|||||||
|
|
||||||
The configuration file can be externalized by using environment variable `DSPACE_APP_CONFIG_PATH`.
|
The configuration file can be externalized by using environment variable `DSPACE_APP_CONFIG_PATH`.
|
||||||
|
|
||||||
|
#### Buildtime Configuring
|
||||||
|
|
||||||
|
Buildtime configuration must defined before build in order to include in transpiled JavaScript. This is primarily for the server. These settings can be found under `src/environment/` folder.
|
||||||
|
|
||||||
|
To override the default configuration values for development, create local file that override the build time parameters you need to change.
|
||||||
|
|
||||||
|
- Create a new `environment.(dev or development).ts` file in `src/environment/` for a `development` environment;
|
||||||
|
|
||||||
|
If needing to update default configurations values for production, update local file that override the build time parameters you need to change.
|
||||||
|
|
||||||
|
- Update `environment.production.ts` file in `src/environment/` for a `production` environment;
|
||||||
|
|
||||||
|
The environment object is provided for use as import in code and is extended with he runtime configuration on bootstrap of the application.
|
||||||
|
|
||||||
|
> Take caution moving runtime configs into the buildtime configuration. They will be overwritten by what is defined in the runtime config on bootstrap.
|
||||||
|
|
||||||
#### Using environment variables in code
|
#### Using environment variables in code
|
||||||
To use environment variables in a UI component, use:
|
To use environment variables in a UI component, use:
|
||||||
|
|
||||||
@@ -183,7 +199,6 @@ or
|
|||||||
import { environment } from '../environment.ts';
|
import { environment } from '../environment.ts';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Running the app
|
Running the app
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@ import { makeStateKey } from '@angular/platform-browser';
|
|||||||
import { Config } from './config.interface';
|
import { Config } from './config.interface';
|
||||||
import { ServerConfig } from './server-config.interface';
|
import { ServerConfig } from './server-config.interface';
|
||||||
import { CacheConfig } from './cache-config.interface';
|
import { CacheConfig } from './cache-config.interface';
|
||||||
import { UniversalConfig } from './universal-config.interface';
|
|
||||||
import { INotificationBoardOptions } from './notifications-config.interfaces';
|
import { INotificationBoardOptions } from './notifications-config.interfaces';
|
||||||
import { SubmissionConfig } from './submission-config.interface';
|
import { SubmissionConfig } from './submission-config.interface';
|
||||||
import { FormConfig } from './form-config.interfaces';
|
import { FormConfig } from './form-config.interfaces';
|
||||||
@@ -25,7 +24,6 @@ interface AppConfig extends Config {
|
|||||||
form: FormConfig;
|
form: FormConfig;
|
||||||
notifications: INotificationBoardOptions;
|
notifications: INotificationBoardOptions;
|
||||||
submission: SubmissionConfig;
|
submission: SubmissionConfig;
|
||||||
universal: UniversalConfig;
|
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
defaultLanguage: string;
|
defaultLanguage: string;
|
||||||
languages: LangConfig[];
|
languages: LangConfig[];
|
||||||
|
6
src/config/build-config.interface.ts
Normal file
6
src/config/build-config.interface.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { AppConfig } from './app-config.interface';
|
||||||
|
import { UniversalConfig } from './universal-config.interface';
|
||||||
|
|
||||||
|
export interface BuildConfig extends AppConfig {
|
||||||
|
universal: UniversalConfig;
|
||||||
|
}
|
@@ -14,18 +14,10 @@ import { ServerConfig } from './server-config.interface';
|
|||||||
import { SubmissionConfig } from './submission-config.interface';
|
import { SubmissionConfig } from './submission-config.interface';
|
||||||
import { ThemeConfig } from './theme.model';
|
import { ThemeConfig } from './theme.model';
|
||||||
import { UIServerConfig } from './ui-server-config.interface';
|
import { UIServerConfig } from './ui-server-config.interface';
|
||||||
import { UniversalConfig } from './universal-config.interface';
|
|
||||||
|
|
||||||
export class DefaultAppConfig implements AppConfig {
|
export class DefaultAppConfig implements AppConfig {
|
||||||
production = false;
|
production = false;
|
||||||
|
|
||||||
// Angular Universal settings
|
|
||||||
universal: UniversalConfig = {
|
|
||||||
preboot: true,
|
|
||||||
async: true,
|
|
||||||
time: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// NOTE: will log all redux actions and transfers in console
|
// NOTE: will log all redux actions and transfers in console
|
||||||
debug = false;
|
debug = false;
|
||||||
|
|
||||||
|
5
src/environments/.gitignore
vendored
Normal file
5
src/environments/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
environment.*.ts
|
||||||
|
|
||||||
|
!environment.production.ts
|
||||||
|
!environment.test.ts
|
||||||
|
!environment.ts
|
@@ -1,6 +1,6 @@
|
|||||||
import { AppConfig } from '../config/app-config.interface';
|
import { BuildConfig } from '../config/build-config.interface';
|
||||||
|
|
||||||
export const environment: Partial<AppConfig> = {
|
export const environment: Partial<BuildConfig> = {
|
||||||
production: true,
|
production: true,
|
||||||
|
|
||||||
// Angular Universal settings
|
// Angular Universal settings
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
// This configuration is only used for unit tests, end-to-end tests use environment.production.ts
|
// This configuration is only used for unit tests, end-to-end tests use environment.production.ts
|
||||||
|
import { BuildConfig } from 'src/config/build-config.interface';
|
||||||
import { RestRequestMethod } from '../app/core/data/rest-request-method';
|
import { RestRequestMethod } from '../app/core/data/rest-request-method';
|
||||||
import { NotificationAnimationsType } from '../app/shared/notifications/models/notification-animations-type';
|
import { NotificationAnimationsType } from '../app/shared/notifications/models/notification-animations-type';
|
||||||
import { AppConfig } from '../config/app-config.interface';
|
|
||||||
|
|
||||||
export const environment: AppConfig = {
|
export const environment: BuildConfig = {
|
||||||
production: false,
|
production: false,
|
||||||
|
|
||||||
// Angular Universal settings
|
// Angular Universal settings
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
// `ng test --configuration test` replaces `environment.ts` with `environment.test.ts`.
|
// `ng test --configuration test` replaces `environment.ts` with `environment.test.ts`.
|
||||||
// The list of file replacements can be found in `angular.json`.
|
// The list of file replacements can be found in `angular.json`.
|
||||||
|
|
||||||
import { AppConfig } from '../config/app-config.interface';
|
import { BuildConfig } from '../config/build-config.interface';
|
||||||
|
|
||||||
export const environment: Partial<AppConfig> = {
|
export const environment: Partial<BuildConfig> = {
|
||||||
production: false,
|
production: false,
|
||||||
|
|
||||||
// Angular Universal settings
|
// Angular Universal settings
|
||||||
|
@@ -30,7 +30,9 @@ const main = () => {
|
|||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasValue(environment.universal) && environment.universal.preboot) {
|
||||||
return bootstrap();
|
return bootstrap();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ const main = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// support async tag or hmr
|
// support async tag or hmr
|
||||||
if (hasValue(environment.universal) && environment.universal.preboot === false) {
|
if (hasValue(environment.universal) && !environment.universal.preboot) {
|
||||||
main();
|
main();
|
||||||
} else {
|
} else {
|
||||||
document.addEventListener('DOMContentLoaded', main);
|
document.addEventListener('DOMContentLoaded', main);
|
||||||
|
Reference in New Issue
Block a user