-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(store-devtools): add recipe to exclude store-devtools from the b…
- Loading branch information
1 parent
6946e2e
commit 303f9fe
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
projects/ngrx.io/content/guide/store-devtools/recipes/exclude.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Excluding Store Devtools In Production | ||
|
||
To prevent Store Devtools from being included in your bundle, you can exclude it from the build process. | ||
|
||
|
||
## Step 1: Create build specific files | ||
|
||
Create a folder for your build specific files. In this case, it is `build-specifics`. Now create a file for a common build. Within this file, export an array that defines the `StoreDevtoolsModule`. | ||
|
||
<code-example header="build-specifics/index.ts"> | ||
import { StoreDevtoolsModule } from '@ngrx/store-devtools'; | ||
|
||
export const extModules = [ | ||
StoreDevtoolsModule.instrument({ | ||
maxAge: 25 | ||
}) | ||
]; | ||
</code-example> | ||
|
||
Now create a file for a production build (`ng build --prod=true`) that simply exports an empty array. | ||
|
||
<code-example header="build-specifics/index.prod.ts"> | ||
export const extModules = []; | ||
</code-example> | ||
|
||
## Step 2: Import extModules | ||
|
||
Modify `app.module.ts` to include `extModules` in the `imports` array. | ||
|
||
<code-example header="app.module.ts"> | ||
import { extModules } from './build-specifics'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
StoreModule.forRoot(reducers), | ||
// Instrumentation must be imported after importing StoreModule | ||
extModules, | ||
], | ||
}) | ||
</code-example> | ||
|
||
## Step 3: Modify angular.json | ||
|
||
Add a new entry in the `fileReplacements` section in your `angular.json`. For more information on this topic, look at the build section of the angular documentation. [Configure target-specific file replacements](https://angular.io/guide/build#configure-target-specific-file-replacements) | ||
|
||
<code-example header="angular.json"> | ||
"fileReplacements": [ | ||
{ | ||
"replace": "src/app/build-specifics/index.ts", | ||
"with": "src/app/build-specifics/index.prod.ts" | ||
} | ||
] | ||
</code-example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters