Skip to content

Commit 082a5d3

Browse files
smelukovmontogeek
authored andcommitted
docs(configuration) Added additional info about Dynamic entry (#2641)
* Additional info about Dynamic entry * Update src/content/configuration/entry-context.md Co-Authored-By: smelukov <[email protected]> * Update src/content/configuration/entry-context.md Co-Authored-By: smelukov <[email protected]> * fixed pr comments * fixed styles
1 parent 11925a1 commit 082a5d3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/content/configuration/entry-context.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ If a string or array of strings is passed, the chunk is named `main`. If an obje
5959

6060
### Dynamic entry
6161

62+
If a function is passed then it will be invoked on every [make](/api/compiler-hooks/#make) event.
63+
64+
> Note that the make event triggers when webpack starts and for every invalidation when [watching for file changes](/configuration/watch/).
65+
6266
```js
6367
module.exports = {
6468
//...
@@ -75,4 +79,16 @@ module.exports = {
7579
};
7680
```
7781

82+
For example: you can use dynamic entries to get the actual entries from an external source (remote server, file system content or database):
83+
84+
__webpack.config.js__
85+
86+
``` js
87+
module.exports = {
88+
entry() {
89+
return fetchPathsFromSomeExternalSource(); // returns a promise that will be resolved with something like ['src/main-layout.js', 'src/admin-layout.js']
90+
}
91+
};
92+
```
93+
7894
When combining with the [`output.library`](/configuration/output#output-library) option: If an array is passed only the last item is exported.

0 commit comments

Comments
 (0)