Skip to content

Commit

Permalink
feat: avoid adding dev features
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Feb 6, 2025
1 parent 55afc04 commit ef281e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
28 changes: 13 additions & 15 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import {
enableProdMode,
importProvidersFrom,
provideExperimentalZonelessChangeDetection,
isDevMode,
} from '@angular/core';

import { environment } from './environments/environment';
import { AppComponent } from './app/app.component';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { provideStore } from '@ngrx/store';
import { provideRouterStore, routerReducer } from '@ngrx/router-store';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
Expand Down Expand Up @@ -44,21 +42,20 @@ bootstrapApplication(AppComponent, {
app: appFeature.reducer,
router: routerReducer,
},
{
metaReducers: debugMetaReducers,
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
strictStateSerializability: true,
strictActionSerializability: true,
strictActionTypeUniqueness: true,
},
},
environment.production
? {}
: {
metaReducers: debugMetaReducers,
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
strictStateSerializability: true,
strictActionSerializability: true,
strictActionTypeUniqueness: true,
},
},
),
provideEffects(appEffects),
provideStoreDevtools({
logOnly: !isDevMode(),
}),
provideRouterStore(),

provideHttpClient(withInterceptors([authInterceptor])),
Expand All @@ -68,5 +65,6 @@ bootstrapApplication(AppComponent, {
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
useValue: { appearance: 'outline', subscriptSizing: 'dynamic' },
},
environment.providers,
],
}).catch((err) => console.error(err));
13 changes: 10 additions & 3 deletions scripts/setup-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ front.forEach((key) => {
const prodConfig = JSON.stringify({
...frontConfig,
production: true,
providers: [],
});

const devConfig = JSON.stringify({
const devBaseConfig = JSON.stringify({
...frontConfig,
production: false,
});
}, null, 2);

const devConfigWithProviders = `${devBaseConfig.slice(0, -1)},
providers: [provideStoreDevtools({ maxAge: 25 })]
}`;

writeFileSync(
'./apps/web/src/environments/environment.prod.ts',
Expand All @@ -37,5 +42,7 @@ writeFileSync(

writeFileSync(
'./apps/web/src/environments/environment.ts',
`export const environment = ${devConfig};`
`import { provideStoreDevtools } from '@ngrx/store-devtools';
export const environment = ${devConfigWithProviders};`
);

0 comments on commit ef281e7

Please sign in to comment.