Used to configure custom page entries.
For most scenarios, the entry automatically generated by Modern.js based on the directory structure can meet the requirements. For details, please refer to Entry.
If you need to customize page entries, you can set them through this option.
When the value of the entries
object is of type string
, it represents the file path of the entry module:
By default, the configured entry is equivalent to App.[jt]sx
, which means that the specified entry file only needs to export the root component of the application.
For example, the following directory structure:
The above directory does not conform to the directory structure convention of Modern.js, so Modern.js will not get any default entries when analyzing the directory structure.
If you do not want to change the directory structure (such as project migration), you can customize the entry through source.entries
:
When the value is Object
, the following attributes can be configured:
entry
: string
, the entry file path.disableMount
: boolean = false
, disable Modern.js's behavior of automatically generating entry code.customBootstrap
: string = ''
, specify the file path of custom Bootstrap.By default, the configured entry is equivalent to App.[jt]sx
, and Modern.js will automatically generate an entry file to reference the entry you configured.
If you want to disable the logic of Modern.js automatically generating entry files, you can set the disableMount
property to true
.
If you need to enable conventional routing for a custom entry, you can set entry
to a directory path:
After setting source.entries
, if disableDefaultEntries: true
is not set, Modern.js will merge the custom entry with the entry obtained by analyzing the directory structure.
The merge rule is:
For example, the following directory structure:
Modern.js will analyze the src/
directory and get the default entries chat
and home
. When the user configures as follows in the modern.config.ts
file:
It can be seen that the path of the custom entry index
is the same as the path of the default entry home
. During the merge process, index
will override home
, and the final entry is as follows:
chat -> ./src/chat/App.tsx
index -> ./src/home/index.ts