File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,52 @@ patchState(this.store, { loading: false });
88
88
updateState (this .store , ' update loading' , { loading: false });
89
89
```
90
90
91
+ ` withDevtools() ` is by default enabled in production mode, if you want to tree-shake it from the application bundle you need to abstract it in your environment file.
92
+
93
+ <details >
94
+
95
+ <summary >Devtools tree-shaking details</summary >
96
+
97
+ environment.ts:
98
+ ``` typescript
99
+ import { withDevtools } from ' @angular-architects/ngrx-toolkit' ;
100
+
101
+ export const environment = {
102
+ storeWithDevTools: withDevtools
103
+ }
104
+ ```
105
+
106
+ environment.prod.ts
107
+ ``` typescript
108
+ import { withDevtoolsStub } from ' @angular-architects/ngrx-toolkit' ;
109
+
110
+ export const environment = {
111
+ storeWithDevTools: withDevToolsStub
112
+ }
113
+ ```
114
+
115
+ Then all you need to do is replace ` withDevTools ` everywhere in your app with ` environment.storeWithDevTools `
116
+ e.g.:
117
+ ``` typescript
118
+ export const SomeStore = signalStore (
119
+ withState ({strings: [] as string [] }),
120
+ environment .storeWithDevTools (' featureName' )
121
+ );
122
+ ```
123
+
124
+ Also make sure you have defined file replacements in angular.json prod configuration:
125
+ ``` json
126
+ "fileReplacements" : [
127
+ {
128
+ "replace" : " src/environments/environment.ts" ,
129
+ "with" : " src/environments/environment.prod.ts"
130
+ }
131
+ ]
132
+ ```
133
+
134
+ </details >
135
+
136
+
91
137
## Redux: ` withRedux() `
92
138
93
139
` withRedux() ` bring back the Redux pattern into the Signal Store.
Original file line number Diff line number Diff line change 1
1
export {
2
+ withDevToolsStub ,
2
3
withDevtools ,
3
4
patchState ,
4
5
updateState ,
Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ export function reset() {
79
79
storeRegistry . set ( { } ) ;
80
80
}
81
81
82
+ /**
83
+ * Stub for DevTools integration. Can be used to disable DevTools in production.
84
+ */
85
+ export const withDevToolsStub : typeof withDevtools = ( ) => store => store ;
86
+
82
87
/**
83
88
* @param name store's name as it should appear in the DevTools
84
89
*/
You can’t perform that action at this time.
0 commit comments